Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Quickselect with median-of-medians pivots (10 marks) In class, we saw a worst-ca

ID: 3756954 • Letter: Q

Question

Quickselect with median-of-medians pivots (10 marks)

In class, we saw a worst-case analysis of Quickselect using median of medians pivots. This pivot was the median of those medians taken from n/5 groups (each group being of size 5), and the resulting runtime was O(n). Show that if we instead use n/9 groups of size 9, then the resulting runtime is still O(n). To analyze the recurrence relationship, you may use the stack of bricks recursion, the substitution method, or another proof technique of your own choosing.

Explanation / Answer

If we take the median of median pivot of group of size n then then running time complexity is O(n)

For group of n/9 size of 9(n>5)

If n is small, for example n<6, just sort and return the k the smallest number.( Bound time-7)

If k=r, then return m

T (n)=O (n) + T (n/5) +T (7n/10)

We will solve this equation in order to get the complexity.

We assume that T (n)< C*n

T (n) = a*n + T (n/5) + T (7n/10)

C*n >= T(n/5) +T(7n/10) + a*n

C*n >= C*n/5+ C*7*n/10 + a*n

C >= 9*C/10 +a

C/10 >= a

C >= 10*a

There is such a constant that exists….so T (n) = O (n)