[SOLVED] CS 340 Project I: Sorting (and Heaps)

25.00 $

Category:

Description

5/5 - (1 vote)

Description:You are to implement InsertionSort, MergeSort, and HeapSort, including the efficient linear time BuildHeap procedure for the latter. You are to use each of the three sorting methods to sort subsets of given wordlists and report upon the overall time complexities of all three algorithms.

Specifications: I have provided you with the said subsets of the wordlists, namely 10 subsets of the small permuted wordlist and 10 of the small sorted wordlist. The permuted input files are of the form perm<size>.txt where the size indicates how many words (lines) the file has, and the sorted input files are sorted<size>.txt. E.g., perm15K.txt has 15,000 words, sorted30K.txt has 30,000 words, etc..
I did this so that you will have 10 data points for each list in your plots. And, indeed you should run each of the three algorithms, InsertionSort, MergeSort, and HeapSort, on all 20 input files. For each run, generate output files of the form IS15K.txt, …, IS150K.txt, MS15K.txt, …, MS150K.txt, HS15K.txt, …, HS150K.txt For debugging purposes, you may conveniently check if each <algorithm><size>.txt file is the same as the corresponding sorted<size>.txt file. However, you are also supposed to run the sorting algorithm on not only the permuted files but also the already sorted ones, both because the algorithm itself does not necessarily know beforehand that a file is sorted and because you need to check how the time complexity is affected. Moreover, you will also be measuring the runtime of BuildHeap separately, in addition to the total runtime of HeapSort, and the runtimes of InsertionSort and MergeSort.
Plots and Report: In your report, you will need to include at least two plots, one for the permuted inputs and another for the already sorted ones, where you demonstrate the runtime of the four algorithms (InsertionSort, MergeSort, HeapSort, and BuildHeap) as a function of the input size. Therefore, you will also have at least 10 data points for each
algorithm of each plot (for each file size multiple of 15K). Based upon your plots, you need to explicate the following in your report: For each of the four mentioned algorithms, what is the expected asymptotic behavior, and do your plots reflect that behavior accurately? Why or why not? You need to reflect on this both for the permuted and the already sorted input cases.
What to turn in: You must turn in a single zipped file containing your source code, a REPORT as described soon, a README file indicating how to execute your program,
and a Makefile if needed for compilation. Read proglag.pdf for further descriptions on allowable programming languages and platforms.