brain

tamnd's digital brain — notes, problems, research

43815 notes

TAOCP 6.4 Exercise 3

The proposed program computes a hash address using only a very small and fixed portion of each key $K$, namely the characters accessed by the instructions $LDI\ K(1!:!1)$ or $LDIN\ K(4!:!1)$, $LD2\ K(...

taocpmathematicsalgorithmsvolume-3medium
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 6.2.2 Exercise 39

Let $w_1,\dots,w_n$ be nonnegative with $w_1+\cdots+w_n=1$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.6 Exercise 7

We restart from the actual optimization principle used in Exercises 5.

taocpmathematicsalgorithmsvolume-3hard
TAOCP 5.2.5 Exercise 6

The key issue in the previous argument is not the final probabilistic model, but the unjustified claim that pile-wise conditional contributions remain independent in a way that produces a product of t...

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.1 Exercise 6

We consider successful search in a sorted table of size $N$, with all keys equally likely.

taocpmathematicsalgorithmsvolume-3hard
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 6.2.3 Exercise 33

Let $T$ be an AVL tree in the sense of Section 6.

taocpmathematicsalgorithmsvolume-3medium
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 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.2.5 Exercise 9

Let a signed magnitude key be a $p$-tuple $(s, a_2, a_3, \dots, a_p),$ where $s \in {0,1}$ is the sign digit and $(a_2,\dots,a_p)$ is the magnitude expressed in radix $M$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2.1 Exercise 2

Let step S4 in Algorithm S be the comparison step that determines whether the current key $K$ should be inserted before $K_i$ or whether $K_i$ should be moved right.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.4 Exercise 29

Working

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.4 Exercise 8

We restart from the correct structure and avoid any use of invalid fractional-part algebra.

taocpmathematicsalgorithmsvolume-3math-hard
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 6.1 Exercise 7

The probability distribution (5) is p_k = 2^{-k}\quad (1 \le k \le N-1), \qquad p_N = 2^{-(N-1)}.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.3.3 Exercise 1

The previous solution fails because it replaces Carroll’s actual tournament mechanism with an invented dominance-based rule and then reasons about that artificial system.

taocpmathematicsalgorithmsvolume-3
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.3 Exercise 15

Let $T$ be the binary search tree representing an ordered linear list, with fields $\text{KEY}(P)$ and $\text{RANK}(P)$ in each node $P$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 44

The previous solution failed because it replaced the actual dependent probing process by an unjustified permutation model.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 5.4.2 Exercise 1

The reviewer is correct on all four failure points.

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 6.2.2 Exercise 25

The main issue in the previous solution is that it never uses a usable structural form of the relation.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.2 Exercise 31

Let $K_a(n)$ denote the number of ordered (plane) rooted trees with $n$ nodes in which every leaf is at distance exactly $a$ from the root.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.2.3 Exercise 4

Let $R_j$ be the number of right-to-left maxima among $K_1,\dots,K_j$.

taocpmathematicsalgorithmsvolume-3
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.3.2 Exercise 12

We restart the argument cleanly and avoid any reliance on incorrect monotonicity substitutions.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.4 Exercise 2

The previous solution fails because it never executes the MIX program in Table 1 and never derives an actual address from the algorithm.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.2 Exercise 30

Let $T=P+1\ge 3$ tapes be given.

taocpmathematicsalgorithmsvolume-3project
TAOCP 5.3.2 Exercise 2

Let $m=1$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 51

Let $X(a,n)$ denote the random variable whose expectation is $R(a,n)$ as defined in (55).

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.1 Exercise 23

Let the given search algorithm be represented by a finite decision tree $T$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.2 Exercise 19

The previous solution fails because it replaces the actual construction of Caron’s polyphase schedule with an unproven symmetry argument.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.3 Exercise 29

The previous argument failed because it replaced the actual recursive structure of a digital search tree by an unjustified occupancy limit.

taocpmathematicsalgorithmsvolume-3hm-project
TAOCP 5.4.9 Exercise 2

Working

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.1.4 Exercise 12

Let A(x_1,\ldots,x_n) denote the alternating polynomial introduced in this section.

taocpmathematicsalgorithmsvolume-3hm-medium
TAOCP 6.2.3 Exercise 13

Storing the index of each node as its key forces the keys to represent a global linear order.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 6.2.2 Exercise 33

Let keys $1,\dots,n$ have search probabilities $p_1,\dots,p_n$ and external probabilities $q_0,\dots,q_n$ as in Section 6.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 6.1 Exercise 17

Let a schedule be a permutation $a_1 a_2 \dots a_n$ of the jobs $1,2,\dots,n$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.3.2 Exercise 11

The sequence is defined explicitly by g_0 = \lfloor 4\cdot 2^0 \rfloor,\qquad g_{k+1} = \lfloor 2^{g_k} \rfloor.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 6.4 Exercise 57

Let the table have size $M$, and let $n$ records be present, so exactly $M-n$ locations are empty.

taocpmathematicsalgorithmsvolume-3math-research
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.4 Exercise 73

Let $M$ be the range of hash values $\{0,1,\dots,M-1\}$.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.4 Exercise 49

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

taocpmathematicsalgorithmsvolume-3hm-medium
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 5

We restart from the correct inequality and determine the full integer solution set carefully.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.2 Exercise 17

A correct solution must start from a precise dual of Algorithm D and then state explicit, local pointer and tag updates that maintain inorder threading in all cases.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.1 Exercise 20

We restart from a correct model of TAOCP replacement selection (“natural selection”) and avoid any assumption of independence or uniform heap ranks.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.2.3 Exercise 6

We analyze the algorithm of Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.9 Exercise 11

Working

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.2.1 Exercise 2

We analyze the modified versions of Algorithm B under the assumption that the table is sorted strictly increasing, k_1 < k_2 < \cdots < k_n, and that the key $K$ is present, with unique index $p$ such...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 52

From equation (42), $Q_o(M,N)$ is given by the finite sum Q_o(M,N)=\sum_{k=0}^{N} \binom{N}{k}\frac{k!

taocpmathematicsalgorithmsvolume-3hm-medium
TAOCP 6.2.2 Exercise 13

We restart from the permutation model, since this avoids any circular use of symmetry or exchangeability.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.2.4 Exercise 7

Let $T$ and $T'$ be B-trees of order $m > 3$ such that every key in $T$ is strictly less than every key in $T'$.

taocpmathematicsalgorithmsvolume-3hard
TAOCP 6.3 Exercise 25

We now give a fully corrected TAOCP-style solution, aligning directly with recurrence (4) for $A_N$ and definition (5) for $C_N$, and avoiding heuristic arguments.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.3 Exercise 2

Let the search path for the insertion end at the new node $Q$, and let the path from the root $R$ to $Q$ be R = v_0, v_1, \dots, v_k = Q.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.3 Exercise 3

Let $T$ be a balanced tree in the sense of Section 6.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.3 Exercise 19

The expression in the prompt is clearly truncated, but the surviving fragment “$k>2$” together with the parameters $s>0$, $m>1$, and the cross-reference to Exercise 5.

taocpmathematicsalgorithmsvolume-3hm-medium
TAOCP 5.4.1 Exercise 15

Let the algorithm be replacement selection with a selection tree containing $P$ external nodes as defined in Section 5.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.3.3 Exercise 10

Solution to TAOCP 5.3.3 Exercise 10.

taocpmathematicsalgorithmsvolume-3math-research
TAOCP 6.3 Exercise 6

Algorithm D inserts keys one at a time.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 5.2.5 Exercise 4

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

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.1 Exercise 4

We restart the construction from the correct replacement-selection algorithm (Knuth, sorting by replacement selection with a min-heap of size 4).

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.2 Exercise 7

Let keys $1,2,\dots,n$ be inserted in random order to form a binary search tree by Algorithm T.

taocpmathematicsalgorithmsvolume-3math-medium
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.3.2 Exercise 20

Fix $m<n$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.3.3 Exercise 7

The previous argument fails because it replaces Floyd’s comparison accounting with informal “reuse” claims and an invalid decomposition into independent subproblems.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.1 Exercise 22

We reconstruct the argument in a fully standard comparison-model framework and remove all heuristic claims.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 5.2.5 Exercise 5

The previous solution’s structural idea is essentially correct, but the running-time analysis must be rebuilt using Knuth’s original definition of the cost components of Program R, in which the parame...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.2 Exercise 38

Let $s_0, s_1, \ldots, s_n$ be arbitrary distinct keys.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.3 Exercise 24

The error in the previous solution is not a minor combinatorial slip.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.4.6 Exercise 11

The core failure in the previous solution is not the lack of prose, but the absence of any actual instantiation of Chart A and Table 1 into computable expressions.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.2 Exercise 28

The previous solution failed to align with TAOCP macro-language conventions because it relied on undefined return semantics and did not specify a formal output interface.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.1 Exercise 28

Let $T_0(x)=x*x$, $T_1(x)=x$, and for $n \ge 0$, T_{n+2}(x)=T_{n+1}(x) * T_n(x).

taocpmathematicsalgorithmsvolume-3math-medium
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.4.8 Exercise 6

The reviewer is correct that the previous argument failed at the single-trajectory constraint.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.2.2 Exercise 30

We prove the equivalent form of the quadrangle inequality: c(i,j)-c(i,j-1)\;\ge\;c(i+1,j)-c(i+1,j-1), \qquad j>i+1, which is equivalent to

taocpmathematicsalgorithmsvolume-3math-hard
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 5.2.3 Exercise 11

Let elements arrive in a sequence at times $t = 1,2,\ldots$.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 6.2.2 Exercise 11

We restart the counting from the actual behavior of step D3, since the previous argument misidentified what is being counted.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.1 Exercise 1

After Step 3 the current front keys of the four runs are $503,\ 170,\ 426,\ 612$ after the replacement of $154$ by $426$.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 6.4 Exercise 58

Uniform probing, in the sense of Theorem U, corresponds to generating a probe sequence by selecting a permutation of the table addresses ${0,1,2,3,4}$ uniformly from the set of all $5!$ permutations.

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.9 Exercise 18

Let $S$ be the number of elevator stops required by a fixed scheduling method applied to a uniformly random permutation of the $bn$ people among the $bn$ desks.

taocpmathematicsalgorithmsvolume-3hm-hard
TAOCP 6.4 Exercise 55

The previous argument failed at the very start because it assumed a functional equation without deriving the Schay–Spruth state recursion.

taocpmathematicsalgorithmsvolume-3hm-project
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 6.1 Exercise 18

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

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.4.1 Exercise 10

The flaw in the previous argument is the assumption that LOSER pointers are merely passive storage.

taocpmathematicsalgorithmsvolume-3hard
TAOCP 6.2.2 Exercise 22

Let e[i,j]=\min_{k=i}^j\bigl(e[i,k-1]+e[k+1,j]+w[i,j]\bigr), \qquad r[i,j]\in\arg\min.

taocpmathematicsalgorithmsvolume-3math-medium
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 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 37

Let $(P_1,\dots,P_n)$ be uniformly distributed over the simplex $P_k>0,\quad \sum_{k=1}^n P_k = 1.$ The entropy is $H(P_1,\dots,P_n) = -\sum_{k=1}^n P_k \log P_k.$ By symmetry, $\mathbb{E}[H(P_1,\dots...

taocpmathematicsalgorithmsvolume-3hm-hard
TAOCP 6.4 Exercise 64

Let $M$ be the table size and $\alpha=n/M$.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.1 Exercise 24

We construct a correct solution directly from the complete binary tree representation, without relying on any claim about equivalence with ordinary binary search.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.3.1 Exercise 7

Let the computation be represented by a binary comparison tree.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.4 Exercise 41

Let $M$ be the table size and $N$ the number of occupied cells under simple uniform hashing, so that all $\binom{M}{N}$ occupied sets are equally likely.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 5.4.9 Exercise 1

Let $f(\theta)$ denote the optimal single–arm latency function for a request starting at position $\theta$, with \int_0^1 f(\theta)\,d\theta = 4(1-x^2).

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.2 Exercise 11

A clean proof must eliminate the earlier two failures: (i) treating both objects as sharing an unproved “common recurrence,” and (ii) conflating a string position with a numeric statistic without grou...

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.1 Exercise 27

Let $P$ denote the capacity of the selection tree (priority queue), and let $P' < P$ denote the size of the reservoir used in natural selection.

taocpmathematicsalgorithmsvolume-3hm-hard
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