(Solved) : 1 Merge Sort Insertion Sort Programs Implement Merge Sort Insertion Sort Sort Array Vector Q26197494 . . .
1) Merge Sort and Insertion Sort Programs Implement merge sortand insertion sort to sort an array/vector of integers.
You may implement the algorithms in the language of your choice,name one program “mergesort” and the other “insertsort”.
Your programs should be able to read inputs from a file called“data.txt” where the first value of each line is the number ofintegers that need to be sorted, followed by the integers.
Example values for data.txt: 4 19 2 5 11 8 1 2 3 4 5 6 1 2
The output will be written to files called “merge.out” and“insert.out”.
For the above example the output would be: 2 5 11 19 1 1 2 2 3 45 6
2) The goal of this problem is to compare the experimentalrunning times of the two sorting algorithms.
a) Now that you have proven that your code runs correctly usingthe data.txt input file, you can modify the code to collect runningtime data. Instead of reading arrays from a file to sort, you willnow generate arrays of size n containing random integer values from0 to 10,000 and then time how long it takes to sort the arrays.
b) Use the system clock to record the running times of eachalgorithm for n = 1000, 2000, 5000, 10,000, …. You may need tomodify the values of n if an algorithm runs too fast or too slow tocollect the running time data. If you program in C your algorithmwill run faster than if you use python. You will need at leastseven values of t (time) greater than 0. If there is variability inthe times between runs of the same algorithm you may want to takethe average time of several runs for each value of n.
c) For each algorithm plot the running time data you collectedon 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 thedata from both algorithms together on a combined graph. Whichgraphs represent the data best?
d) What type of curve best fits each data set? Again you can useExcel, Matlab, any software or a graphing calculator to calculate aregression equation. Give the equation of the curve that best“fits” the data and draw that curve on the graphs of created inpart c).
e) How do your experimental running times compare to thetheoretical running times of the algorithms? Remember, theexperimental running times were “average case” since the inputarrays contained random integers.
f) Generate best case and worst case input for both algorithmsand repeat the analysis in parts b) to d) above.
Expert Answer
Answer to 1 Merge Sort Insertion Sort Programs Implement Merge Sort Insertion Sort Sort Array Vector Q26197494 . . .
OR