9-3 Small order statistics

We showed that the worst-case number T(n)T(n) of comparisons used by SELECT\text{SELECT} to select the iith order statistic from nn numbers satisfies T(n)=ฮ˜(n)T(n) = \Theta(n), but the constant hidden by the ฮ˜\Theta-notation is rather large. When ii is small relative to nn, we can implement a different procedure that uses SELECT\text{SELECT} as a subroutine but makes fewer comparisons in the worst case.

a. Describe an algorithm that uses Ui(n)U_i(n) comparisons to find the iith smallest of nn elements, where

Ui(n)={T(n)if iโ‰ฅn/2,โŒŠn/2โŒ‹+Ui(โŒˆn/2โŒ‰)+T(2i)otherwise. U_i(n) = \begin{cases} T(n) & \text{if $i \ge n / 2$}, \\ \lfloor n / 2 \rfloor + U_i(\lceil n / 2 \rceil) + T(2i) & \text{otherwise}. \end{cases}

(Hint:\textit{Hint:} Begin with โŒŠn/2โŒ‹\lfloor n / 2 \rfloor disjoint pairwise comparisons, and recurse on the set containing the smaller element from each pair.)

b. Show that, if i<n/2i < n / 2, then Ui(n)=n+O(T(2i)lgโก(n/i))U_i(n) = n + O(T(2i)\lg(n / i)).

c. Show that if ii is a constant less than n/2n / 2, then Ui(n)=n+O(lgโกn)U_i(n) = n + O(\lg n).

d. Show that if i=n/ki = n / k for kโ‰ฅ2k \ge 2, then Ui(n)=n+O(T(2n/k)lgโกk)U_i(n) = n + O(T(2n / k)\lg k).

(Removed)