Question: Problem 10 (10 points). Show execution of Selection on the given vector A of integers. For each recursive call, show the following: 1) Show low,

 Problem 10 (10 points). Show execution of Selection on the givenvector A of integers. For each recursive call, show the following: 1)

Problem 10 (10 points). Show execution of Selection on the given vector A of integers. For each recursive call, show the following: 1) Show low, high 2) vector medians filled in with medians of 5-integer sub-ranges of A 3) pivot (the median of the medians) 4) swap pivot with A[high] 5) Partition A around pivot, show partitioned A; circle pivot after partition 6) Show pivot index 1 int selection (vector A, int low, int high, int k) { 2 if (size S 5) 3 insertion (A, low, high); //sort the range return A[k]; vector medians; 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!