Question: a) Implement the STOOGESORT algorith to sort an array of integers using C or C++. Your program should be able to read inputs from a
a) Implement the STOOGESORT algorith to sort an array of integers using C or C++. Your program should be able to read inputs from a file called data.txt where the first value of each line is the number of integers that need to be sorted, followed by the integers. The output will be written to a file called stooge.out.
b) Modify the code from part a 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 and then time how long it takes to sort the arrays.You will need at least seven values of t (time) greater than 0. If there is variability in the times between runs of the algorithm you may want to take the average time of several runs for each value of n. *(show the code modifications)
c) Plot the running time data you collected on an individual graph with n on the x-axis and time on the y-axis.
d) What type of curve best fits the StoogeSort data set? Give the equation of the curve that best fits the data and draw that curve on the graphs of created in part c). How does your experimental running time compare to the theoretical running time of the algorithm?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
