Question: You need to analyze your code for various test cases and provide a the analysis for the following experiments in the report. You need to
You need to analyze your code for various test cases and provide a the analysis for the following experiments in the report. You need to add the functions in timing.cpp file to report for the experiments:
Compare the time complexity of the insertion sort with three different input cases. Generate first
vector with random integers of various sizes already provided in the timing cpp file Follow the
instructions in timing.cpp to generate enough data points to observe a trend. Generate second vector
with sorted integers of various sizes. Generate third vector with reverse sorted integers of various sizes.
The size set you are using should be same for all cases. Find the time taken by the algorithms for
the three cases of input. Plot a graph with xaxis label indicating varying input size of the vector
and yaxis label the experimental time in seconds reported by your implementation. There should
be three curve lines each corresponding to the three different input cases. Describe your observations
from the plot and what inference statement you can derive about the results.
Compare the time complexity of the traditional merge sort when k with three different input
cases. Generate first vector with random integers of various sizes already provided in the timing
cpp file Generate second vector with sorted integers of various sizes. Generate third vector with
reverse sorted integers of various sizes. Find the time taken by the algorithms for the three cases of
input. Plot a graph with xaxis label indicating varying input size of the vector and yaxis label the
experimental time in seconds reported by your implementation. There should be three curve lines
each corresponding to the three different input cases. Describe your observations from the plot and
what inference statement you can derive about the results.
Compare the time complexity of the merge sort algorithm on different value of k Generate a vector
with random integers of various sizes. Choose three different values of k:
already provided in the
timing cpp file
Plot a graph with xaxis label indicating varying input size of the vectorand
list and yaxis label the experimental time in seconds reported by your implementation. There
should be curves corresponding to three k values and traditional merge sort with k Describe
your observations from the #include
#include
#include
#include
#include
#include
#include
#include "sort.h
using namespace std;
using namespace chrono;
@todo Modify timing.cpp to evaluate the various sorting algorithms on the
following input types:
Random sequence
Sorted sequence
Reverse sorted sequence @brief Generate random sequence and insetionsort
@param k merge sort subproblem size not used
@param sz Vector size
duration insertionsortrandomsequenceksizet sz sizet k
vector v;
forsizet i ; i sz; i
vpushbackrand;
create a clock
highresolutionclock::timepoint start highresolutionclock::now;
myalgorithm::insertionsortvbegin vend less;
calculate time
highresolutionclock::timepoint stop highresolutionclock::now;
duration diff d @brief Generate random sequence and sort
@param k merge sort subproblem size
@param sz vector size
duration mergesortrandomsequenceksizet sz sizet k
vector v;
forsizet i ; i sz; i
vpushbackrand;
create a clock
highresolutionclock::timepoint start highresolutionclock::now;
myalgorithm::mergesortvbegin vend less k;
calculate time
highresolutionclock::timepoint stop highresolutionclock::now;
duration diff durationcaststop start;
return diff;
@brief Control timing of single function
template
void timefunctionFunc f sizet maxsize, sizet k string name
cout "Function: name endl;
cout setw "Size" setw "Timesec endl;
control input size
forsizet i ; i maxsize; i
cout setw i;
duration diff;
loop a specific number of times to make the clock tick
sizet numitr maxsizet maxsize i;
forsizet j ; j numitr; j
diff fi k;
cout setw diff.count numitr endl;
@brief Main function to time all your functions
int main
timefunctioninsertionsortrandomsequencek pow "Insertion Sort Random Sequence";
timefunctionmergesortrandomsequencek pow "Merge Sort traditional Random Sequence";
timefunctionmergesortrandomsequencek pow pow "Merge Sort Random Sequence k;
@TODO Add more function calls based on report
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
