Question: Any help would be much appreciated!! Write a program in C++ to benchmark and compare the performance of the heapsort and quicksort. Your program should
Any help would be much appreciated!!
Write a program in C++ to benchmark and compare the performance of the heapsort and quicksort. Your program should randomly generate three integer arrays of N=102, 104, and 106 elements and run either heapsort or quicksort to sort the arrays in increasing and decreasing orders. Then run both heap sort and quick sort on the three sorted arrays and the three reverse-ordered arrays and output the following complexity/performance measures for both algorithms on each of the 6 arrays (one in ascending order and one in descending order for each size):
1. number of comparisons performed between values in the input array, and
2. actual execution times in appropriate time units such as microseconds, milliseconds, etc.
In addition to regularly required documents for project submissions, submit an MS Word or Adobe Pdf file that includes a table summarizing the outputs of your program on the six input arrays and discuss about whether the performance of the heap sort and quick sort on those arrays is consistent with their theoretical worst-case running times given in lecture? If not, why?
Note: For the two sorting algorithms, heap sort and quick sort, you can implement them on your own, or use any existing programs such as implementation of the pseudocode given in lecture, the code from the textbook or other programs downloaded from internet. You must, however, indicate the source of sorting programs you use and the tie-breaking rule adopted (in case two array elements equal each other).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
