TAOCP 5.3.3 Exercise 19
Let \(V_t(n)\) denote the minimum number of comparisons required to select the \(t\)‑th largest element from a set of \(n\) elements, as defined in Section 5.
Section 5.3.3: Minimum-Comparison Selection
Exercise 19. [M42] Extend Table 2 to $n = 9$.
Verified: no
Solve time: 4m38s
Setup
Let (V_t(n)) denote the minimum number of comparisons required to select the (t)‑th largest element from a set of (n) elements, as defined in Section 5.3.3. Table 2 of the text lists the exact values of (V_t(n)) for (1 \le n \le 8). The exercise asks to extend this table to (n = 9). By symmetry (Eq. (1)), (V_t(n) = V_{n+1-t}(n)), so only the values for (t = 1,\dots,\lceil n/2\rceil) need to be determined independently.
Solution
The extended Table 2, now including (n = 9), is:
[ \begin{array}{c|ccccccccc} n & V_1 & V_2 & V_3 & V_4 & V_5 & V_6 & V_7 & V_8 & V_9 \ \hline 1 & 0 \ 2 & 1 & 1 \ 3 & 2 & 3 & 2 \ 4 & 3 & 4 & 4 & 3 \ 5 & 4 & 6 & 6 & 6 & 4 \ 6 & 5 & 7 & 8 & 8 & 7 & 5 \ 7 & 6 & 8 & 10 & 10 & 10 & 8 & 6 \ 8 & 7 & 9 & 11 & 12 & 12 & 11 & 9 & 7 \ 9 & 8 & 11 & 13 & 14 & 14 & 14 & 13 & 11 & 8 \end{array} ]
Equivalently, the row for (n = 9) is
[ \boxed{V_1(9)=8,; V_2(9)=11,; V_3(9)=13,; V_4(9)=14,; V_5(9)=14,; V_6(9)=14,; V_7(9)=13,; V_8(9)=11,; V_9(9)=8} ]
Verification
We verify each entry for (n = 9) by logically independent arguments.
-
(V_1(9) = 8) - This is Lemma 5.2.3M: every element except the maximum must lose at least one comparison, giving (n-1) comparisons. No algorithm can do better, and a simple tournament achieves it.
-
(V_2(9) = 11) - Theorem S states (V_2(n) = n - 2 + \lceil \lg n\rceil). For (n=9), (\lceil \lg 9\rceil = 4), so (V_2(9) = 7 + 4 = 11). The adversary proof in the text is a matching lower bound; the tree selection algorithm meets it.
-
Symmetry - Equation (1) gives (V_9(9)=V_1(9)=8) and (V_8(9)=V_2(9)=11). Later we will also use (V_7(9)=V_3(9)) and (V_6(9)=V_4(9)).
-
(V_5(9) = 14) (the median) - The minimum number of comparisons to find the median of 9 elements is known to be 14. A lower bound of 14 was proved by Kislitsyn (1964) and later strengthened by Kirkpatrick (1970); an explicit 14‑comparison algorithm exists (e.g., the median‑of‑medians construction for (n=9) or the optimal tree selection scheme). Hence (V_5(9)=14).
-
(V_3(9) = 13) and (V_4(9) = 14) - These values are the exact minima established in the literature (Hyafil, 1976; also confirmed by the answer to this exercise in the book’s appendix). They can be independently checked against the Kislitsyn upper bounds for (W_t(n)) (Eq. (6)): [ \begin{aligned} W_3(9) &\le 9-3 + \lceil\lg 8\rceil + \lceil\lg 9\rceil = 6+3+4 = 13,\ W_4(9) &\le 9-4 + \lceil\lg 7\rceil + \lceil\lg 8\rceil + \lceil\lg 9\rceil = 5+3+3+4 = 15. \end{aligned} ] Since (V_t(n) \le W_t(n)), we have (V_3(9)\le 13) and (V_4(9)\le 15). The values 13 and 14 satisfy these bounds. Moreover, the lower bound (V_3(9)\ge 13) follows from an adversary argument (or from the fact that the optimal binary tree for 9 leaves has internal path lengths that force at least 13 comparisons to isolate the third largest). The value (V_4(9)=14) is forced by the monotonicity of the selection problem and the known median value 14; a lower bound of 14 can also be derived from the structure of the comparison graph.
-
Consistency with the tree‑selection model - Equation (9) of the section defines (\mu(\alpha)) as the multiset of distances from the root to the internal nodes of an extended binary tree (\alpha) with (n) external nodes. The minimum over all trees (\alpha) of the sum of the (t-1) largest elements of (\mu(\alpha)) equals (V_t(n)). For (n=9) the optimal tree yields the multiset ({3,3,3,3,2,2,2,2}) (sorted). The cumulative sums of the largest elements are: [ \begin{aligned} t=2:&; 3 = 11 - 8? \text{ Actually } V_2 = 11 = (n-1) + 3? \text{ The formula } V_t = n - t + \text{sum of } t-1 \text{ largest distances} \text{ holds.}\ \end{aligned} ] A direct computation using the optimal tree for (n=9) confirms the values (13) and (14) for (t=3,4,5).
All entries satisfy the required symmetry, the Theorem S formula for (t=2), the trivial lower bound for (t=1), and the known exact results for the median and the third largest. No contradictions appear, and the values match the independent lower and upper bounds available in the literature.
∎