Name: _____________________________ October 9, 2015 Time Comparisons of Sorting Algorithms For this lab, a random set of numbers has been generated and stored in a file named "rand.dat". A subset of the numbers will be sorted using 3 different algorithms: bubble, insertion, and quick sort. The amount of time (in seconds) needed for each sort will be displayed. Then another set of sorts will be executed on a larger set of numbers. The point of this lab is: Notice what happens to execution time for bubble and insertion when array size is increased by a factor of n. Appreciate how much faster a quick sort is. Download the source file (timeCompare.cpp) and the .dat file (rand.dat) from D2L. Place the files in a VS project. Compile and run. Fill in this table as the program runs Seconds required to sort Number of data items sorted Sorting Algorithm Bubble Sort Insertion Sort Quick Sort 1000 5000 10,000 50,000 100,000 200,000 300,000 Look at the results for bubble sort and fill in this table. To calculate the "factor" value for each column divide the 2nd number by the first. I have filled in the first 2 under input size. 10,000 / 5,000 = 2. Now divide the execution time for 10,000 by the execution time for 5000. Bubble Sort Input size increased by a factor of From 5000 to 10000 2 From 10,000 to 50,000 5 Execution time increased by a factor of From 5000 to 50,000 From 50,000 to 100,000 From 50,000 to 300,000 From 100,000 to 200,000 From 100,000 to 300,000 How would you express execution time as a function of input size? ______________________ Now do the same thing for insertion sort. To calculate the "factor" value for each column divide the 2nd number by the first. I have filled in the first 2 under input size. 10,000 / 5,000 = 2. Now divide the execution time for 10,000 by the execution time for 5000. Insertion Sort Input size increased by a factor of From 5000 to 10000 2 From 10,000 to 50,000 5 Execution time increased by a factor of From 5000 to 50,000 From 50,000 to 100,000 From 50,000 to 300,000 From 100,000 to 200,000 From 100,000 to 300,000 How would you express execution time as a function of input size? ______________________ Now do you see why bubble sort and insertion sort belong to O(n2) ?