Groups Of Three

Median of medians picks its pivot by splitting the input into groups of 5, taking each group's median, and recursing to find the median of those medians. The 6.046 analysis shows at least 3(⌈n/10⌉−2)3(\lceil n/10 \rceil - 2) elements fall on each side of that pivot, which yields

T(n)=T ⁣(n5)+T ⁣(7n10+6)+Θ(n)T(n) = T!\left(\frac{n}{5}\right) + T!\left(\frac{7n}{10} + 6\right) + \Theta(n)

and this solves to Θ(n)\Theta(n). A student proposes groups of 3 instead, since sorting a group of 3 is cheaper. What does that change?

A

The algorithm becomes incorrect: the pivot is no longer guaranteed to have the claimed rank, so the wrong element can be returned

B

The two subproblem sizes become about n/3n/3 and 2n/32n/3, which sum to exactly nn, so the recursion becomes Θ(nlog⁡n)\Theta(n \log n)

C

It stays Θ(n)\Theta(n) with a smaller constant, because sorting groups of 3 costs less per group

D

It stays Θ(n)\Theta(n), because 1/31/3 and 2/32/3 are each strictly less than 1