Question: iven the following sort roid sortRec(vector & A, int n) { if(n==1) return; sortRec(A, n - 1); int i; int tmp = A[n - 1);

 iven the following sort roid sortRec(vector& A, int n) { if(n==1)

iven the following sort roid sortRec(vector& A, int n) { if(n==1) return; sortRec(A, n - 1); int i; int tmp = A[n - 1); i = n-1; while (>0 && A[i-1] >tmp) { A[] = A[i-1]; } A[i] = tmp: } Modify the function so the number of comparisons are counted Write a program that will Generate 3 vectors for an inputted size o One vector for the best case o One vector for the worst case o One vector for the average case . For the best and worst case vector only run the sort once to get the count . For the average case you will have to run the sort serval times(100) on different ordered values in the vector and calculate the average number of comparisons . Once you have all your counts for the three cases print them For size X Number of comparisons for best case is X Number of comparisons for worst case is X Number of comparisons for average case is X

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!