9-3 Small order statistics
We showed that the worst-case number T(n) of comparisons used by SELECT to select the ith order statistic from n numbers satisfies T(n)=ฮ(n), but the constant hidden by the ฮ-notation is rather large. When i is small relative to n, we can implement a different procedure that uses SELECT as a subroutine but makes fewer comparisons in the worst case.
a. Describe an algorithm that uses Uiโ(n) comparisons to find the ith smallest of n elements, where
Uiโ(n)={T(n)โn/2โ+Uiโ(โn/2โ)+T(2i)โif iโฅn/2,otherwise.โ
(Hint: Begin with โn/2โ disjoint pairwise comparisons, and recurse on the set containing the smaller element from each pair.)
b. Show that, if i<n/2, then Uiโ(n)=n+O(T(2i)lg(n/i)).
c. Show that if i is a constant less than n/2, then Uiโ(n)=n+O(lgn).
d. Show that if i=n/k for kโฅ2, then Uiโ(n)=n+O(T(2n/k)lgk).
(Removed)