Sorting Comparison Assignment
CS 362 - Spring 2011 - Ms. Katz

Due
in my mailbox no later than noon Friday, April 22 (worth 60 points of in-class activity)

Goals
- to compare the runtime performance of various sorting algorithms
- to realize which algorithm you use does matter

Overview
This is an in-lab hands-on activity comparing sorting algorithms. We will do it during the class period on Friday, April 22. If you get it to me before then, you are excused from class.

You write no code. The sort implementations are from the Ford and Topp textbook as is the timing code. The heap sort is a make_heap and sort_heap from the STL algorithm library.

The driver fills vectors with the same random numbers and runs the sorts on the vectors. The sorts considered are radix sort, merge sort, quicksort, quicksort with final insertion sort, heap sort, insertion sort, and selection sort. They are the Ford and Topp text's implementations compiled with the -O3 optimization option to the C++ compiler. Optimization substantially increased the speeds.

You will complete two pages of a paper lab report on which you graph your observations. Turn in that report (both pages). If you do so by email, try to have a reasonably small file that is crisp and easy to read. It's probably better to start with the digital file and record your result in a drawing program rather than scan your paper. There is nothing to submit.

The Driver
The driver is an executable program in    ~katz362/support/sortlab
The -f option requests that only the fast algorithms be run. Providing a positive integer no bigger than 15 million will use that size vector. The largest vector allowed for the slower sorts is 300,000.

To run all the algorithms with 50000 items in the vectors, use    ~katz362/support/sortlab 50000

To run the non-quadratic (fast) algorithms with 500,000 items in the vectors, use
   ~katz362/support/sortlab -f 500000
Use the up arrows keys to change the command slightly.

The driver will run locally, so you will affect only your own machine. If you are doing this lab from home, please do a 'w' command to see if someone else is using your chosen machine. If anyone else is on that machine, log off and use a different machine.

The Lab Report
Along with this assignment description, you received two chart to record your observations; one for the quadratic sorts and one for the faster sorts: PDF quadratic or PNG quadratic or PDF fast or PNG fast
If you plan to send this to me by email, consider putting the png files into a drawing program (for example, import png file into a Google Docs drawing) and build your report digitally.

Print your name and the machine you are using on both reports. Note that the graph paper shows thousands of items along the bottom axis and time along the vertical axis. Pay attention to the units. The faster sort graph is in two parts because the bottom increments change. You will fill in both parts.

Start by running the driver with 10000 items. Mark the reported times on the quadratic graph with clearly visible dots. You don't have to be exact. The fast sorts will be zero at this point. There is no need to record the zeros or very close to zeros.

Record what happens with 20000, 40000, and 60000 items. Don't draw a line connecting the results of the same sort. Just record them and think about what is happening. Record in the space at the bottom of the quadratic report how long it takes to run the quadratic sorts on 100,000 items.

When the quadratic sorts can no longer be recorded, add the -f flag to your command. Continue checking the faster sorts at 100,000, 300,000, 500,000, and 1,000,000 items. Note the name of the sort near its trend of dots in the empty space between the graph parts. Do not try to draw a line through them. Sometimes, repeat the same run. There may be some variation related to a data set leaning toward the best-case or worst-case scenario. Pay attention to any unexpected results and repeat those runs.

Check the fast sorts on millions of items. When a sort's time no longer fits on the chart, ignore it.
Clearly mark which trend of dots corresponds to which sort.