CS1210 Computer Science 1 - Fall 2021
Due Monday, Nov. 8, by 2:00pm
1. Compare six sorting methods and produce a document discussing your results. You will be graded on the quality of your test data, the effectiveness of your charts/graphs, and your written discussion of the results.
Start with the code in hw7sorts.py. The file includes four sorting methods: selection, insertion, merge, and builtin (Python's built-in sort), plus some commented-out pylab code that can serve as a model for your graphing/charting code.
Your report must have three sections:
- You must compare six sorting methods: selection, insertion, merge, and Python's built-in sort, plus quicksort, and any other sort other than bubble sort
- You may search the Internet (or books) quicksorts to use. But be careful! It's easy to find "bad" ones - use knowledge of quicksort from lecture 31 to find a good one.
- The other sort can be any other one you find on the web or in books (except bubble sort).
- You must compare all of the sorts on three kinds of data - randomly ordered, already sorted, and reverse sorted.
- You must test on a wide range of list sizes, including very large lists that will adequately demonstrate the differences in performance between the fast sorting methods.
- Each chart you include in your report should show list size (x axis) vs. running time in seconds (y axis) for multiple sorts. The plotted curves for different sorts should be different colors/styles and a legend or caption should make it clear which curve corresponds to which sort (e.g. red curve: selection sort, blue curve: quicksort, ...)
For each of these sections, write a couple of a sentences explaining what the charts tell you about the sorting methods and how the charts match with expected O(n), O(n log n), O(n^2) behaviors of the methods.
- Comparison of all sorts on random data. This section should have two charts, one for all the sorts or just the relatively slow sorts, with data up to sizes in the tens of thousands. You won't likely be able to see much difference between the faster sorts on this first chart. The second chart should be just for the faster sorts on data up to sizes of hundreds of thousands or even millions of items.
- Comparison of all sorts on already sorted data. Again, there should be two charts.
- Comparison of all sorts on reverse sorted data. Again, there should be two charts.
Note: You may include more analysis, additional data and charts if you wish, but the above is what's required for full credit.
For this assignment, submit two things:
- one Python file containing everything in the original hw7sorts.py plus what you added - the code
you used to generate your test data, timing results, and graphs/charts, and the additional sorting methods.
- a pdf document containing your write-up.
NOTE: .doc,.rtf, and similar documents are not acceptable! Convert to pdf before submitting (via "Save As" or similar means)