Sorting and Efficiency Solution

For this assignment, you will experiment with two different sorting algorithms, insertion sort and

heap sort.

1.       Write a main program that can be used to compare the performance of these two  algorithms. Your program should prompt the user for the number of items to be sorted,  then construct a vector of that many random integers. It should then perform each of the sorts on that vector and time how long it takes (using the clock function from the ctime  library). The time for each sort should be displayed in a readable format. (5 points)

2.       Perform 3 different executions of your program on each of the following list sizes: 500  items, 1000 items, 2000 items, and 4000 items. Report your timings in a table such as the  one below. (10 poins)

500 items

Insertion SORT:

1st timing:

2nd timing:

3rd timing:

Heap SORT:

1st timing:

2nd timing:

3rd timing.

1000 items

2000 items

4000 items
Powered by