Programming Assignment 3
Due: Mar. 31 by 5pm
Description
Assignment 3 focuses on implementation and analysis of sorting algorithms. You are to implement bubble sort, a slow sorting algorithm, and a fast sorting algorithm, and deeply analyze their complexities and trade-offs. You will make a report of your findings.
Program Requirements
- Starting code is found here.
- Put your name at the top of any file you edit with a comment block.
- You can make all of the code at once with the command
make
, all of the documentation again with the commandmake docs
. - Unit testing is provided to aid you in determining if your implementation is correct, however, note the tests are not exhaustive! If all tests are reported to pass, this is only part of the process. If you are not convinced your code is correct, please add more tests.
- Comments with
TODO
define all necessary tasks to complete the assignment, but there is not many hints beyond that. Some items to consider:- Code documentation. Nice output will be found in
Docs
. Openindex.html
in your web browser of choice to see an interactive documentation system. Please note all comments, some tell how the functions should be implemented, what variable names mean, etc. - Textbook implementation of the sorts (note these may not match 100%).
- Code documentation. Nice output will be found in
- You need to implement bubble sort, one slow sort, and one fast sort.
- The options for slow sort are (choose one):
- Insertion Sort (in place)
- Selection Sort (in place)
- The options for fast sort are (choose one):
- Heap Sort (in place)
- Merge Sort
- Quick Sort (in place)
- In addition, you will modify
Timing.java
to analyze your solutions on the following types of input:- Random
- Already sorted
- Reverse sorted
- A few unique elements
Report Requirements
Your report will include the objective of the assignment, brief description of your implementation, and a discussion of your results (theoretical and experimental). At a minimum your report should include the following organized into sections. Use a technical writing style and typeset your report in LaTeX. In this report, you are to design your own experiment to analyze big-oh complexity of your sorting algorithms.
- Introduction. In this section, state or describe the objective of the assignment, a statement about what you learned in the assignment, and a statement summarizing your results.
- Implementation details. Give a brief description of how you implemented the assignment, including what you learned.
- Theoretical analysis. In this section, you should provide a theoretical analysis (i.e., Big-Oh) for each of the three sorting algorithms in regards to your experiment(s). You should mention best, average, and worst case times if it is pertinent to the experiment and algorithms you chose. You do not need to reason about memory complexity.
- Experimental Setup. In this section, you should provide a description of your experiment setup, which includes but is not limited to Machine specification, i.e., processor type, amount of ram, OS, etc.
- Results & Discussion.
In this section, you will deeply analyze the performance of the various
sorting algorithms.
Include and discuss plots connecting data back to
theoretical discussions per designed experiment. For each input type and
each array plot:
- Plot input size vs. time.
- Plot input size vs. time/expected time to determine the Big-Oh constants.
O(n2)
test the following input sizes:21, 22, ..., 215
. For operations which takeO(n log n)
test the following input sizes:21, 22, ..., 220
. - Conclusion. Summarize your findings.
Bonus
Each extra sorting algorithm you implement and compare with in your report will earn you bonus points. 2 points per extra algorithm implementation and 3 points for each extra analysis. So in total you can earn 20 more points. (The other one of insertion/selection, the other two of heap/merge/quick, and radix sort). You may also earn an extra five points for designing one more type of comparison that explores the effect of data size being sorted. As in, some sorts utilize the cache more effectively, so if you bring the size of a single element of the array to be much larger, this breaks the efficiency gains of the sort.General Instructions, Turning in assignments, and Grading
General Instructions
- Name each file and program as listed in the instructions (if there are new files to create).
- The top of each file you modify should have a comment of your name.
- Use proper coding style (described more in Grading below)
- Follow turn-in instructions precisely.
- Failure to complete any of these steps will result in a significant loss of points.
Turn in Instructions
Each assignment will be turned in to both Blackboard (soft copy) and in class (hard copy). Assignments are due BEFORE, let me repeat, before class starts. This does not mean five minutes after class starts.
- Soft copy (Online submission)
- Create a compressed
.zip
file of all Java programs needed to compile your program and all input files (if needed) to run your program.- If you do not know how to create a compressed
.zip
file, there is this cool new website you can use to search for instructions by entering"How to create .zip Windows 10"
or"How to create .zip MAC OSX"
for example.
- If you do not know how to create a compressed
- Submit
.zip
file on Blackboard by the stated due date and time. - Submit a
.pdf
file on Blackboard of your report by the stated due date and time. This will be a separate turnin from the code.
- Create a compressed
- Hard copy (In-class submission)
- The first page of your hard copy must be a signed coverpage.
- Next put the programs (only the ones you wrote code in) in order as
described in the description.
- If you do not know how to print a java file, there is this cool
new website you can use to
search for instructions by entering
"How to open and print .java file Windows 10"
or"How to open and print .java file MAC OSX"
for example. In combination with this, you may have to consult University of Richmond webpages to learn how to use campus printers. I recommend printing directly from sublime text editor on University computers (has printing feature enabled) and will print with syntax-highlighting (colors).
- If you do not know how to print a java file, there is this cool
new website you can use to
search for instructions by entering
- Staple all pages together.
- Turn in packet before class begins.
- With a separate signed coverpage print out and turn in your report.
- I reserve the right to assign a 0 to any assignment failing to comply with these instructions. Even for something as small as a missing staple.
Points
- Each assignment is graded out of 100 points (not including bonus). 50 points for the report and 50 points for the code.
- Criteria and point distribution
- If the code is not named precisely or does not compile, -75% of the code.
- If the code does not generate the correct output, -50% of the code.
- Following instructions and algorithm used to solve, 25% of the code. Following instructions is extremely important in computer science, train yourself to think like a computer. There are many ways to solve a problem, some may be better or worse than others.
- Stylistic elements of written code,
25% of the code. Style includes (but is not
limited to):
- Descriptive comments on intent and purpose of code
- Descriptive and consistant naming conventions
- Indenting properly (after an opening brace, tab right by 1 indent; after a closing brace, tab left by 1 indent)
- Consistent spacing
- Consistent bracket placement (same line or on new line)
- Avoiding code duplication
- Content of written report, 80% of the report.
- Clarity and style of written report, 20% of the report.
- If there are any discrepencies in grades please see the instructor during his office hours or by appointment (do not discuss with the lab assistants or graders).