CS 302 - Data Structures

Fall 2016

Programming Assignment 4 : Sorting

Due on Tuesday, Nov 1 at 4:00 pm

Programming Problem 9 on Page 332 (include the counting sort and bucket sort)

The object of this programming assignment is twofold. You are to compare the relative performance of different sorting algorithms on the same data set and the same algorithm on different data sets.

Choose a sorting algorithm from each of the O(n^2) (i.e., selection, insertion and buble), O(n logn) (i.e., merge and quick), and O(n) (i.e., counting, bucket and radix) categories.

Randomly generate (1000, 10000, and 100000) integer values (in the range of 0 to 1000000) to be inserted into the data structures. Note that the list (i.e., the input values) itself should not be sorted and all algorithms should use the same input file when the input size is same.

Also, test the speed of algorithms when the input array is already sorted (for the same input data).

The following output should be provided for an average of 10 sorts of each algorithm and input size:

  1. the CPU time (note that generation processes should not affect these values)
  2. the number of comparisons
  3. the number of swaps

Bonus [2 points]: Run the algorithms with 1000000 values.

Note: You can only use (i.e., copy) code from the book and slides. You need to develop the rest of the code yourself.

You can run 2 instances of algorithms that take more than one hour.

Deliverables: (as source code or a pdf file)

  1. Source code for your classes (one for each sort algorithm for a total of 3)
  2. Doxygen reports for code documentation
  3. A main file that tests the classes with randomly generated data.
  4. Test output of your algorithms (with a tabulau of each run and their averages)

Teaching Assistant: Shehryar Masaud

What to turn in: A softcopy of your sourcecode and reports should be uploaded to WebCampus. Combine the files in a single zip file.