Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Start with the code in sorts.py. The file includes three sorting methods: select

ID: 3703387 • Letter: S

Question

Start with the code in sorts.py. The file includes three sorting methods: selection, insertion, merge, and builtin (Python's built-in sort).

For this problem, you must add two additional sorting functions to the file and compare the running times of all of the sorting functions on a variety of data. Make sure you use large enough and varied enough data!

One of the sorting functions you must add is quicksort. The other can be any other method you find (except bubble sort). You may search the Internet (or books) for Python implementations to use. Be careful with quicksorts found on the web! It's easy to find "bad" ones - use knowledge of quicksort from lecture 31 to find a good one.

The write-up will likely be several pages. It should (a) describe how you generated test data (2) include graphs, charts, and/or tables of your timing results (these must be images of things generated by Python - no hand-made graphs/charts/tables!), and (c) discuss conclusions about the relative performance of the various sorts. This should include, where appropriate, assessment of best/average/worst base behavior, and of how performance data fits with what we know about the Big-O running time bounds of these methods.

sorts.py:

Explanation / Answer

selectionSort(A)

insertionSort(A)

merge(A)

def selectionSort():

       ms = Timer("merge()", "from_main_import merge")

       print ms.timeit()

       is = Timer("insertionSort()", "from_main_import insertionSort")

       print is.timeit()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote