Question: *********************************************** Example values for data.txt: 3 18 1 5 12 8 3 3 5 4 6 6 2 2 *********************************************************** Merge Sort vs Insertion Sort

***********************************************

Example values for data.txt:

3 18 1 5 12

8 3 3 5 4 6 6 2 2

***********************************************************

Merge Sort vs Insertion Sort Running time analysis

The goal of this problem is to compare the experimental running times of the two sorting algorithms.

a) Now that you have proven that your code runs correctly using the data.txt input file, you can modify the code to collect running time data. Instead of reading arrays from a file to sort, you will now generate arrays of size n containing random integer values from 0 to 10,000 and then time how long it takes to sort the arrays. We will not be executing the code that generates the running time data so it does not have to be submitted or even execute . Include a text copy of the modified code in writing .

b) Use the system clock to record the running times of each algorithm for n = 1000, 2000, 5000, 10,000, . You may need to modify the values of n if an algorithm runs too fast or too slow to collect the running time data. If you program in C your algorithm will run faster than if you use python. You will need at least seven values of t (time) greater than 0. If there is variability in the times between runs of the same algorithm you may want to take the average time of several runs for each value of n.

c) For each algorithm plot the running time data you collected on an individual graph with n on the x-axis and time on the y-axis. You may use Excel, Matlab, R or any other software. Also plot the data from both algorithms together on a combined graph. Which graphs represent the data best?

d) What type of curve best fits each data set? Again you can use Excel, Matlab, any software or a graphing calculator to calculate a regression equation. Give the equation of the curve that best fits the data and draw that curve on the graphs of created in part c).

e) How do your experimental running times compare to the theoretical running times of the algorithms? Remember, the experimental running times were average case since the input arrays contained random integers

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!