Question: Problem 5. Show execution of Select on the given vector A of integers. Follow lecture slides format (assume that sorting of 5-integer groups is done

 Problem 5. Show execution of Select on the given vector A

Problem 5. Show execution of Select on the given vector A of integers. Follow lecture slides format (assume that sorting of 5-integer groups is done in-place, i.e. inside the vector). Show recursive calls in the order of their execution (show only recursive calls at line 15 or 17). For each recursive call, show the following: 1) low, high 2) vector medians filled in with medians of 5-integer sub-ranges of A 3) pivot (the median of the medians) 4) Range A[low, high) after partition at line 11 (before doing partition, swap pivot with A[high]) 5) p 1 int selection (vector A, int low, int high, int k) { 2 if (size 35) 3 insertion (A, low, high); //sort the range return A[k]; vector medians; 6 For each 5-integer sub-range of A do: sort the sub-range using insertion in place push back the median of the sub-range to medians 9 pivot = selection (medians, 0, medians.size - 1, medians.size/2) 10 pivotIndex = findPivot (A, pivot)//scan A return index of pivot 11 p = partition (A, low, high, pivotIndex) 12 if (k == p) 13 return A[p] 14 else if (k

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!