Computer Science 261
Exercise set #9
Due: Tuesday, Dec. 7 (in class)
Consider the file quicksort.cpp in the handouts folder on Plato.
The file demonstrates how the random number generator can be used to
generate several copies of an array to sort, and how sorting
algorithms may be timed.
In this exercise, I would like for you to do one of the following
two experiments, with the results written up (using a word
processor):
- (experiment 1): Compare the behavior of (bubblesort or
insertion sort) with that of quicksort and also either (heapsort
or Shellsort). You should run each sorting algorithm on identical
(randomly generated) arrays of increasing size, plotting the total
time against array size.
- (experiment 2): Compare the behavior of quicksort with at
least two versions of ShellSort: one version using powers of 2 for
gaps, and a second version using some other method for calculating
gaps. Possible candidates include the version suggested in the
textbook, or using numbers in the Fibonacci sequence (1, 2, 3, 5,
8, 13, ...)
In each case, your report should include
- Listings of the programs used to run the tests
- Raw data from the runs
- Graphs of these runs
- Conclusions (order n^2, order nlog(n), etc.)
All of this should be turned in in word processed form (i.e., no
handwritten parts), stapled together in the order given above, with
your name on the first page.
Please let me know if there are any questions or problems. Many
thanks!