Bard College – Computer Science – Data Structures
In this lab we will create a program to compare different sorting algorithms on a variety of inputs. The five sorts we will explore are:
insertion sort ( Insertion.sort )
selection sort ( Selection.sort )
quick sort ( Quick.sort )
heap sort ( Heap.sort )
merge sort ( Merge.sort )
Sorting Benchmark
Write a program that measures and reports the running times for the different sorting algorithms. At the minimum it should report the average(i.e. mean) running time for 100 experiments per configuration. You might also include support for computing the minimum, maximum, variance, and median. Use the StopwatchCPU to measure the running times of the sorts. Report the run-times in milliseconds.
Varying Input Sizes
Start with an array of 512 items, and increase in powers of two, up to 32,768(215).
Varying Input Types
Choose a reasonable input size and explore sorting five different kinds of input data:
uniformly random numbers between 0-1 that are already sorted in ascending order;
uniformly random numbers between 0-1 that are already sorted in descending order;
random numbers between 0-1 that are mostly sorted.(You can define what mostly means);
random numbers from the set of 1, 2, 3 and 4.
Submission
Write a report detailing your findings including tables and graphs. If you want extra Java practice, you can graph the results using the methods in textbook's StdDraw.
Bring a hard-copy of your lab report and code to class on Friday. Also, submit via Google Classroom a zip file that expands to a folder with at least the following two files:
cmsc201-lab5-lastname-firstname
SortingBenchmark.java
lab5.pdf
BONUS CHALLENGE: Mystery Sorts
Can you identify which sort & data-set resulted in the following results?
Sorting Benchmark
Varying Input Sizes
Varying Input Types
Submission
cmsc201-lab5-lastname-firstname
SortingBenchmark.java
lab5.pdf
BONUS CHALLENGE: Mystery Sorts