CMPU-203: Introduction to Computer Science III

Project #6
Due: Friday, Dec. 14

In ~weltyc/public_html/cs203/proj6/ you will find code for testing a suite of sort algorithms. The program to run is:

sorttest sorttype dataset size
Where:

sorttype is one of: BubbleSort, BidirectionalBubbleSort, MergeSort, InsertionSort, HeapSort, ShellSort, SelectionSort, QuickSort, QubbleSort, FastQuickSort.

dataset is a number between 0 and 7, where 0 is a random dataset, 1 is a convex dataset, 2 is a concave dataset, 3 is a Dutch-flag dataset, 4 is a 10-color dataset, 5 is a reverse sorted dataset, 6 is a nearly-sorted dataset, and 7 is an already sorted dataset.

size is an integer indicating the size of the container.

Using this program you must run some experiments and do some analysis. To determine the run time of a sort, use the Unix time command, as we did before.

  1. Look at the code in SortAlgorithm.C and attempt to determine the worst-case complexity of each sort algorithm.

  2. For each sort algorithm, record its actual run time for datasets of size 10000-100000, in increments of 5000, for each type of dataset. From this data, you should make a plots for each algorithm of run time vs. n for each dataset. In adition, make a plot of the average run time across all datasets vs. n (i.e. you should have 9 plots for each sort algorithm). You can have the plots on one graph provided the different plots are visibly recognizable.

  3. Analyze your experimental data: estimate the actual run time complexity of each algorithm; discuss if and how it is different than the worst-case complexity and why; for what size/datasets is quicksort not the fastest? Why do you think this is? How could you improve quicksort to overcome this?

You may of course use the animations to help you understand the algorithms.