brain

tamnd's digital brain — notes, problems, research

41266 notes

TAOCP 6.2.2 Exercise 6

Let $P_{n,k}$ denote the number of permutations $a_1,\dots,a_n$ of $\{1,\dots,n\}$ such that, when Algorithm T inserts $a_1,\dots,a_n$ into an initially empty binary search tree, exactly $k$ compariso...

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.4 Exercise 28

Let $X_M$ denote the number of probes required for an unsuccessful search in a linear probing table of size $M$ containing $N$ stored keys.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.1.3 Exercise 2

The claim is that for integers $n,k,q>0$, \binom{n}{q}\binom{k}{q}\in \mathbb{Z}.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.1 Exercise 16

Let the Fibonacci rabbit model be the standard one: a single initial pair is present at month $0$; every pair produces exactly one new pair in each month starting from its second month of life; no pai...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.2 Exercise 1

Let $A$ denote the null pointer used in Algorithm T.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 5.4.2 Exercise 21

In the six-tape case we have $T=6$ and hence $P=T-1=5$.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 6.2.2 Exercise 31

Let C^*(w)=\min_T \sum_{v} w_v d_v(T) be the optimal alphabetic tree cost for the ordered weight sequence

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.2.5 Exercise 4

The reviewer’s objection is correct: simply replacing FIFO queues by LIFO stacks breaks stability.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.3 Exercise 10

The flaw in the previous argument is that it tried to _compute_ subtree validity and heights from the balance-factor sequence before establishing that a subtree actually exists.

taocpmathematicsalgorithmsvolume-3hard
TAOCP 5.2.2 Exercise 5

Let $b_1 b_2 \dots b_n$ be the inversion table of the permutation $a_1 a_2 \dots a_n$.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.2 Exercise 21

The solution fails at the very first structural step: the cost formulas for the five trees are partly incorrect, so everything built on them (inequalities, regions, integrals) is invalid.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.3 Exercise 3

The earlier solution fails primarily because it never instantiates Algorithm C’s actual state mechanism: a 5-way polyphase merge on six tapes driven by a 5-term Fibonacci-type (pentanacci) distributio...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 62

The previous solution incorrectly assumed that the cost functional decomposes as C_y = \frac{1}{M}\sum_K C(K), with each $C(K)$ depending only on the increment sequence assigned to $K$.

taocpmathematicsalgorithmsvolume-3math-research
TAOCP 5.4.9 Exercise 12

Let $T$ be a rooted tree with $n>0$ leaves, and let the degree path length $(6)$ be defined as in Section 5.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 17

In double hashing with open addressing, a key $K$ is examined in the sequence of table positions h_1(K),\; h_1(K) + h_2(K),\; h_1(K) + 2h_2(K),\; \dots \pmod{M}, so that $h_2(K)$ determines the step s...

taocpmathematicsalgorithmsvolume-3simple
TAOCP 6.3 Exercise 11

Algorithm 6.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.2 Exercise 45

Let the sequence maintained by the Garsia–Wachs algorithm be $L = (l_1, l_2, \dots, l_m)$ in symmetric order.

taocpmathematicsalgorithmsvolume-3hard
TAOCP 6.4 Exercise 70

The key fix is to discard the incorrect “uniform random cycle” model and replace it with a correct symmetry argument for double hashing: the probe sequence is not uniform over all permutations, but it...

taocpmathematicsalgorithmsvolume-3hm-project
TAOCP 6.2.3 Exercise 6

Let $B_h(z)$ denote the ordinary generating function in which the coefficient of $z^n$ equals the number of balanced binary trees with $n$ internal nodes and height exactly $h$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.2.2 Exercise 7

Batcher’s merge-exchange method is not stable.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.2.3 Exercise 1

For a fixed value of $j$, step S2 selects the maximum of the keys $K_1,\ldots,K_j$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.5 Exercise 1

Let the tapes be $0,1,\dots,P$, where tape $q$ is the designated output tape and the remaining $P$ tapes are work tapes.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2.4 Exercise 6

Let Algorithm L be the straight two-way merge sort in which the initial step L1 sets the system so that every record $R_i$ forms a run of length $1$, and later steps repeatedly merge runs of fixed siz...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.1 Exercise 5

We restart the analysis from the actual structure of the comparison, without introducing abstract per-iteration cost parameters.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.2 Exercise 8

Let $I_n$ denote the internal path length of the random BST built from $n$ keys.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 5.2 Exercise 3

No.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.4 Exercise 69

The review identifies three genuine failures: an unjustified symmetry factor, an unsupported intermediate bound, and a mismatch between the run decomposition and the claimed inequality.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.1 Exercise 11

We analyze the random-permutation model: all $n!$ input permutations of distinct keys are equally likely.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.2 Exercise 4

Let $p\ge 1$ and let $(F_n)_{n\ge 0}$ satisfy F_n = \sum_{i=1}^p F_{n-i}\qquad (n\ge p), with fixed initial values $F_0,\dots,F_{p-1}$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.3.1 Exercise 1

For $n>0$, the recurrence $P_n=\sum_{k=1}^{n} \binom{n}{k} P_{n-k}$ together with $P_0=1$ is multiplied by $z^n/n!$ and summed over all $n\ge 1$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.1 Exercise 23

A correct analysis must avoid treating the evolving replacement process as i.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.1 Exercise 24

The errors in the previous solution stem from two issues: (i) failure to verify that the transformation “descending run = apply $x \mapsto 1-x$” preserves the structural hypotheses of Theorem K at the...

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.4 Exercise 9

Let M= \begin{pmatrix} q_1&q_2&\cdots&q_n\\ p_1&p_2&\cdots&p_n

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 6.4 Exercise 65

Let a variable-length key $K$ be a finite sequence of MIX characters $K = c_1 c_2 \dots c_\ell,$ where each $c_i$ is an element of a fixed alphabet of radix $r$ (for MIX, typically $r = 64$ or $r = 10...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.1 Exercise 11

We restart from the actual structure of Program C and compute the averages directly from the frequency model, without introducing non-uniform quantities as constants.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.3 Exercise 23

Let $N$ keys be stored in an $M$-ary trie under the uniform random model in which each digit of each key is independently uniformly distributed in ${0,1,\dots,M-1}$.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.3 Exercise 28

Let $T_N$ be the Coffman–Eve $M$-ary digital search tree built from $N$ independent random infinite strings over an alphabet of size $M>2$.

taocpmathematicsalgorithmsvolume-3hm-hard
TAOCP 5.1.4 Exercise 7

Let $P$ be a tableau of shape $(m_1,m_2,\dots,m_k)$, with $m_1 \ge m_2 \ge \dots \ge m_k > 0$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.3 Exercise 29

We analyze a 2–3 tree built by inserting a random permutation of $n$ distinct keys, using the standard top-down insertion algorithm with node splitting.

taocpmathematicsalgorithmsvolume-3math-research
TAOCP 5.4.2 Exercise 16

Let $P = T-1 \ge 2$.

taocpmathematicsalgorithmsvolume-3hm-project
TAOCP 5.4.9 Exercise 6

The previous solution fails because it treats the weight data as missing.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2.3 Exercise 13

**Exercise 5.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 68

Let $S_N = d_1 + d_2 + \cdots + d_N$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.1 Exercise 7

Algorithm R initializes the selection tree by filling all external nodes with the next input records.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.6 Exercise 8

Let the initial distribution place $S$ runs onto $P$ input tapes for a $P$-way merge under Algorithm F in Section 5.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.2 Exercise 29

Let the 31 keys be the most common English words in Fig.

taocpmathematicsalgorithmsvolume-3project
TAOCP 6.4 Exercise 50

By equation (42), the quantity $Q_o(M,N)$ satisfies Q_o(M,N) = 1 + \frac{N}{M} Q_o(M,N-1).

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.8 Exercise 8

We restart from the definition of the condition and first extract its actual global consequence, instead of interpreting it geometrically.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.2.2 Exercise 27

We repair the argument from the ground up and keep only valid structural facts about optimal BSTs.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.3 Exercise 42

Let $K_1, K_2, \dots, K_r$ be the binary keys, each a finite string over ${0,1}$, and let $T$ be the binary trie formed by these keys.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.3.3 Exercise 10

Solution to TAOCP 5.3.3 Exercise 10.

taocpmathematicsalgorithmsvolume-3math-research
TAOCP 5.2.1 Exercise 4

The running time of Program S is $9B+10N-3A-9.$ By the results stated in Section 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.3 Exercise 27

Let $C_N$ denote the quantity defined in equation (14) of Section 6.

taocpmathematicsalgorithmsvolume-3hm-hard
TAOCP 5.4.7 Exercise 2

The earlier solution fails because it imports a Fibonacci _tape-capacity invariant_ from polyphase merging that does not belong to radix distribution.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.1 Exercise 20

The previous solution failed because it tried to analyze the function $\delta(t)=d(t,i)-d(t,i+1)$ directly on the cycle, where it is not monotone and in fact has multiple regime changes.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.3.2 Exercise 2

Let $m=1$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.7 Exercise 5

The original submission contains no construction or argument, so the solution must be rebuilt from the definitions of Mauchly’s read-backwards radix sort and the 4-LIFO representation used in Section...

taocpmathematicsalgorithmsvolume-3simple
TAOCP 6.3 Exercise 31

Let $A_n$ be the expected cost of an $M$-ary digital search tree built from $n$ random keys, and let $P(z)$ be its Poisson transform.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.2 Exercise 23

The reviewer is correct that the original attempt destroys the essential feature of TAOCP §5.

taocpmathematicsalgorithmsvolume-3hard
TAOCP 6.2.2 Exercise 42

Let condition (31) be the 2-descending condition for binary search trees: for every node $P$, every node $Q$ in the subtree rooted at $\mathrm{LLINK}(P)$ satisfies $\mathrm{KEY}(Q) < \mathrm{KEY}(P)$,...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.1.3 Exercise 14

Let w = 3111231423342244 a word on $\{1,2,3,4\}$ having 5 runs (maximal weakly increasing consecutive blocks).

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.1 Exercise 25

The previous solution failed because it tried to _postulate_ a kernel and then retrofit a “memoryless explanation” instead of deriving the joint law from the actual state evolution at the instants whe...

taocpmathematicsalgorithmsvolume-3hm-project
TAOCP 5.4.6 Exercise 6

Algorithm 5.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.2 Exercise 24

Let $T$ be a binary search tree with cost C(T)=\sum_{i=1}^n p_i\,\mathrm{depth}(k_i)+\sum_{i=0}^n q_i\,\mathrm{depth}(d_i), where all $p_i,q_i\ge 0$ and $p_n=q_n=0$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.1 Exercise 9

Let the comparison used in Algorithm R for the selection tree be denoted by $\prec$, where in the original algorithm $a \prec b$ means that key $a$ is smaller than key $b$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2.1 Exercise 9

The flaw in the previous solution is that it never uses the data in Tables 3 and 4.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.6 Exercise 12

Six tapes are partitioned into three logical pairs.

taocpmathematicsalgorithmsvolume-3project
TAOCP 6.4 Exercise 42

Let $M$ be the number of hash addresses and let $n$ be the number of occupied cells at the moment a new key $K$ is inserted by Algorithm C.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.9 Exercise 11

Working

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.2.2 Exercise 2

(a) The permutation $376981452$ has the disjoint cycle decomposition (1\,3\,6\,4\,9\,2\,7)(5\,8).

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.4 Exercise 11

**Exercise 5.

taocpmathematicsalgorithmsvolume-3math-simple
TAOCP 6.4 Exercise 7

Let $F = \mathrm{GF}(2^n)$, and let $a \in F$ be an element of order $n$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.1 Exercise 3

We restart the analysis from the definition of **four-way replacement selection** (TAOCP §5.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2 Exercise 1

Algorithm C still works if $i$ varies from $2$ up to $N$ in step C2 instead of from $N$ down to $2$, because the comparisons made in step C4 depend only on the relative ordering of $K_i$ and $K_j$, no...

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.1 Exercise 19

We restart the analysis from the structure actually used in Algorithm F (as modified in Exercise 14): a Fibonacci tree representation where the search space consists of all internal and external nodes...

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 5.1.3 Exercise 3

Using the binomial theorem, (1-1)^n=\sum_{k=0}^{n}\binom{n}{k}1^{\,n-k}(-1)^k =\sum_{k=0}^{n}\binom{n}{k}(-1)^k .

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.1 Exercise 9

Let Algorithm B denote the standard binary search of Section 6.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.1 Exercise 27

The error in the previous solution is not cosmetic.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.4.7 Exercise 1

The core mistake in the previous argument is the attempt to manufacture a per-level varying radix structure from tape-role behavior.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2.1 Exercise 10

In step D3, Program D performs three actions before any comparison outcome is known: it sets $i = j - h$, it loads $K = K_j$, and it loads $R = R_j$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.3.3 Exercise 9

We construct all values for $V_t(8)$ using a single consistent method: an optimal 8-element tournament followed by explicit optimal selection in the induced comparison structure.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 5.2.5 Exercise 3

At the start, Algorithm H sets $i \leftarrow 0$ and then sets $P \leftarrow \mathrm{TOP}[0]$.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.4 Exercise 49

Let $K$ be the number of records in a fixed bucket.

taocpmathematicsalgorithmsvolume-3hm-medium
TAOCP 5.3.1 Exercise 4

The goal is to determine the sorted order of $n$ keys, knowing each key is either $0$ or $1$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.3.3 Exercise 3

Let $W_t(n)$ denote the worst-case number of comparisons required by any comparison-based algorithm for the structure defined in the exercise.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.2.3 Exercise 2

For the input $N,N-1,\ldots,2,1$, the sequence $K_1, K_2, \ldots, K_j$ is strictly decreasing for every $j \ge 2$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.2 Exercise 11

**Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.1 Exercise 7

The flaw in the previous solution is that it replaces Algorithm U’s interval invariant with a “reachability” heuristic.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.3.1 Exercise 6

Let keys lie in the ordered set $\{1,2,\dots,m\}$, with $m$ fixed, and let $S_m(n)$ be the worst–case number of comparisons needed by an optimal comparison tree that produces a stable sorted order of...

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.1 Exercise 17

Let the Fibonacci tree of order $k$ be defined as usual: a node of order $t$ has a left child of order $t-1$ and a right child of order $t-2$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.1.3 Exercise 11

**Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.2 Exercise 46

The original proof failed because it tried to replace the evolving tree by a “random BST” argument and then imported harmonic search costs that only hold for that model.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.3.3 Exercise 15

The previous proof failed because it incorrectly treated reachability in a general DAG as if it could be incremented only locally per comparison, and then incorrectly decomposed two dependent costs as...

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.4.9 Exercise 31

The previous solution fails because it never reconstructs the _actual performance quantity in TAOCP’s striping model_.

taocpmathematicsalgorithmsvolume-3hm-research
TAOCP 5.1.4 Exercise 6

Let Algorithm S be the full sequence of insertions described in Algorithm I applied successively, terminating with a tableau $P$ and a final added position $(r,s)$ determined at the last insertion ste...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.1 Exercise 26

A correct proof must specify an invariant state of the polyphase algorithm and show that this invariant is exactly the Fibonacci decomposition encoded by Fibonacci trees.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.1.3 Exercise 10

h_k(z)=\sum_{m\ge k}p_{km}z^m is the probability generating function of the total length S_k=L_1+\cdots+L_k

taocpmathematicsalgorithmsvolume-3
TAOCP 5.2.3 Exercise 15

**Corrected Solution for Exercise 5.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.1 Exercise 18

Let the positions be $1,2,\dots,N$.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.4.9 Exercise 27

Let M_n = \max_{0 \le i < n} S_i(m_1,\ldots,m_p) be the maximum load.

taocpmathematicsalgorithmsvolume-3