Computer Science 410: Homework 3
Versions of Quicksort: A Computer Exercise

Homework 3: Handed out: 2/11/99; Due: 2/25/99

Note: This assignment involves programming, which will have to be done using J++ in the CSUGLab. If you haven't set up an account there yet, check the course web page for info. There will also be two short Java tutorials on Friday (Feb. 12), from 12-1 and from 4:30-5:30. The tutorials will be held in the CSUGLab.


Overview: In class we discussed several possible versions of the Quicksort algorithm. These include:

1.
Using A[p] of each subproblem as the pivot.
2.
Considering the A[p], A[r], and A[(p+r)/2] elements of each subproblem and then choosing the middle one as the pivot.
3.
Switching to insertion sort for subproblems below a particular size threshold.

Your job is to implement these three versions of Quicksort and then, through testing, determine the relative performance of these algorithms as a function of input size. You will create an Array class in Java to store a user-specified number of integers, complete with various member functions for accessing and modifying array elements. You will then implement the three versions of Quicksort within a Sorter class. Finally, you will use these two components with a test harness to create and sort randomly filled Array objects of various sizes. Sorting times will be recorded and a report detailing your results will be written.

What we have done for you:

Since this is your first programming exercise, we have provided most of the code framework for you. This includes the files:

Code you must write

The test harness that we have given you is merely an example. For this assignment, you must modify this harness to run timed trials of the three versions of QuickSort on various sized arrays. For example, you might want to modify Tester to create three randomly filled Arrays (all of the same size) and then to run the three versions of QuckSort on the arrays, timing each run and outputting the results. This is merely a suggestion the details are up to you.

For both the Array and Sorter functions, you must be sure NOT to change the names or signatures of any supplied function stubs that you complete. We will be testing your code using our own test harness, and this harness assumes that the function names/signatures are as specified. In other words, if you change the function names/signatures your code WON'T pass our tests.

What you must do:

As mentioned previously, your test harness should run timed trials of the three versions of QuickSort on various sized arrays. Specifically, you should run 10 trials of each method using Arrays of size 10, 100, 1000, and 10000. If you find this range of numbers to be inappropriate for the hardware that you are using, feel free to scale them. For each Array size and method, you should record the range of results, throwing out outliers (i.e., the best and worst result). Additionally, for your version of QuickSort that uses InsertionSort, you should record ranges for various thresholds below which InsertionSort is used: 0, 10, 25, 40.

Your job is to create a 2-3 page lab report and graph interpreting the data. Your report should be formatted appropriately. Although you do not need to follow this outline exactly, make sure you have:

The report should be handed in at the beginning of class on Feb. 25.

Advice and hints:

Submitting your project:

Create a local folder with your NetID (your login) as its name. Copy your project folder containing all .java, .class, and MS Visual J++ files into this folder.

Important: Set the folder permissions so that the TA's (zlt@cs, gupta@cs, jjh14@cornell.edu, rsb11@cornell.edu, ja39@cornell.edu, prf3@cornell.edu, lc47@cornell.edu, melin@cs, welte@cs) and yourself have 'Full Control' access permission, and no one else. Drag this NetID folder onto \\Goose\courses\cs410\A1\Submissions. You will not be able to see your files, and you will only be able to submit once. Ensure your program is working before submitting it.

Grading: