brain

tamnd's digital brain — notes, problems, research

41271 notes

TAOCP 6.2.2 Exercise 29

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

taocpmathematicsalgorithmsvolume-3project
TAOCP 5.4.2 Exercise 1

The reviewer is correct on all four failure points.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 11

The proposed interchange is not valid in general, because it violates a dependency in the control flow of Program C.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.3.2 Exercise 12

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

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.3.2 Exercise 4

Let $\underline{M}(m,n)$ denote the lower-bound function for merging described in Section 5.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 6.2.2 Exercise 2

Let each node $P$ contain fields $\operatorname{KEY}(P)$, $\operatorname{LLINK}(P)$, $\operatorname{RLINK}(P)$, and a tag $\operatorname{RTAG}(P)\in{0,1}$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2.3 Exercise 9

Let the file contain $2^n$ elements and consider the bottom-up method of Fig.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.3 Exercise 13

Let each key be a digit string over an alphabet of size $M$, K = k_1 k_2 \dots k_\ell, \qquad 0 \le k_i < M.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.3 Exercise 11

The exercise statement is incomplete.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 6.4 Exercise 46

Let the table size be $M$, with $n$ stored keys and load factor $p=n/M$.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 5.3.1 Exercise 2

The root node compares $K_1$ and $K_2$.

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

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

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.3 Exercise 17

Let $T$ denote the balanced tree of Fig.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.3 Exercise 2

We compare cascade sorting on three tapes (Algorithm C) with polyphase merging on three tapes (Algorithm 5.

taocpmathematicsalgorithmsvolume-3medium
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 24

Let the sample space consist of all sequences $(K_1,\dots,K_7)$ of seven distinct keys chosen from the set of $MP$ possible keys, with each such sequence having equal probability under successive unif...

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.3.3 Exercise 16

A corrected solution is given below.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.3.1 Exercise 3

We must construct an **extended ternary decision tree for sorting four elements drawn from $\{-1,0,+1\}$** using comparison nodes with outcomes $<,=,>$, and determine a tree with **minimum average num...

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.3 Exercise 4

**Corrected Solution to Exercise 5.

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

Algorithm 6.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.2 Exercise 4

The failure in the previous solution is the incorrect introduction of an inhomogeneous “deviation dynamics.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.6 Exercise 4

We must modify Algorithm F _as it is actually written in TAOCP_, not an abstract version of it.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.1.3 Exercise 6

The mistake is that Mr.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.3 Exercise 26

A $t$-ary tree is a rooted ordered tree in which each internal node has at most $t$ children.

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.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 5.2 Exercise 2

For each pair $(j,i)$ with $j<i$, step C4 increases exactly one of `COUNT[j]` or `COUNT[i]`.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.3 Exercise 4

The previous solution fails because it never uses the actual cascade operator.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.3 Exercise 26

The product is interpreted as P=\left(1-\frac{1}{5}\right)\prod_{k\ge 1}\left(1-\frac{1}{3^k}\right).

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 63

Let the hash table have $M$ locations.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.1.4 Exercise 4

Let a permutation $\pi = a_1 a_2 \cdots a_{n^2}$ of $\{1,2,\dots,n^2\}$.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.3 Exercise 30

Let each available area be represented by a node $P$ with fields $\text{LOW}(P), \text{HIGH}(P), \text{SIZE}(P)=\text{HIGH}(P)-\text{LOW}(P)+1,$ and let all free areas be stored in a balanced binary t...

taocpmathematicsalgorithmsvolume-3hard
TAOCP 5.2.3 Exercise 11

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

taocpmathematicsalgorithmsvolume-3simple
TAOCP 5.4.2 Exercise 24

The error in the previous solution is not the use of Perron–Frobenius itself, but the attempt to justify it through an incorrect state-space model.

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

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

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.3 Exercise 5

Let the keys be $K_y, K_0, K_1, \dots, K_n$ with $K_y < K_0 < K_1 < \cdots < K_n.$ At every stage, Algorithm A inserts the new key as a leaf in the rightmost position of the current tree, since each n...

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.2.3 Exercise 6

We analyze the algorithm of Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.9 Exercise 2

Working

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

We rewrite the argument so that the missing link between the Nielsen condition and _prefix-deterministic behavior in the original free-group alphabet_ is made explicit.

taocpmathematicsalgorithmsvolume-3hm-hard
TAOCP 5.4.9 Exercise 24

Let the $P$ runs be $R_1,\dots,R_P$.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 5.3.3 Exercise 10

Solution to TAOCP 5.3.3 Exercise 10.

taocpmathematicsalgorithmsvolume-3math-research
TAOCP 6.2.2 Exercise 3

Algorithm T performs a search by repeatedly comparing $K$ with $KEY(P)$ and then moving to $LLINK(P)$ or $RLINK(P)$ until either the key is found or the pointer becomes $A$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2.1 Exercise 14

Let $A_{i,j}$ be defined by Eq.

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

The flaw in the previous argument is real: the insertion point cannot depend on the unknown divergence index $d$, so any attempt to define it during the initial search is circular.

taocpmathematicsalgorithmsvolume-3hard
TAOCP 5.4.9 Exercise 14

Let a rooted ordered tree $T$ have $n$ leaves.

taocpmathematicsalgorithmsvolume-3project
TAOCP 5.2.5 Exercise 2

Algorithm R performs a sequence of $p$ distribution passes, each pass grouping records into $M$ FIFO queues according to a single digit $a_{p+1-k}$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.1 Exercise 13

Let $P$ be the number of keys held in the selection tree.

taocpmathematicsalgorithmsvolume-3simple
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 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.2.1 Exercise 13

Start from the standard lattice representation of a permutation used in Section 5.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.2 Exercise 3

No.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.3.2 Exercise 2

Let $m=1$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 10

Let \[ S_j=\{\,\{n\theta+a_j\}:0\le n<N_j\,\},\qquad 1\le j\le d, \] and let \(S=\bigcup_{j=1}^d S_j\).

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 6.4 Exercise 20

In the modified Algorithm D, step D3 sets c\leftarrow0, and each time step D4 is entered, the counter is first increased:

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.2 Exercise 21

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

taocpmathematicsalgorithmsvolume-3simple
TAOCP 5.4.6 Exercise 12

Six tapes are partitioned into three logical pairs.

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

Let $P$ be a pointer to a record, with $FIRST$ pointing to the first record and the last record linked to the sentinel $A$.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 6.2.4 Exercise 6

We restart the construction in a fully TAOCP-consistent form by defining a single recursive deletion procedure in which every descent step is preceded by an invariant-preserving repair.

taocpmathematicsalgorithmsvolume-3medium
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.2.1 Exercise 8

A correct solution must address stability in the sense of TAOCP: records with equal keys must preserve their relative order after the entire Shellsort process.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 6.4 Exercise 6

In MIX arithmetic, the instruction `DIV d` interprets the concatenation $AX$ as a single signed integer formed with $A$ as the high-order word and $X$ as the low-order word.

taocpmathematicsalgorithmsvolume-3simple
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.4.2 Exercise 5

Let f_p(z)=z^p-z^{p-1}-\cdots-z-1,\qquad p>2, and define

taocpmathematicsalgorithmsvolume-3hm-hard
TAOCP 6.3 Exercise 22

Let $X_l$ denote the number of trie nodes on level $l$ in a random $M$-ary trie containing $N$ keys.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.9 Exercise 15

Let the elevator process be measured in stops, and let each stop be a position at which the elevator services requests while its capacity is $b$ and the access structure contributes at most $m$ additi...

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

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

taocpmathematicsalgorithmsvolume-3medium
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 6.4 Exercise 74

Let $H$ be a matrix whose rows are hash functions $h : \mathcal{K} \to {0,1,\dots,M-1}$, and whose columns correspond to keys.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.4.8 Exercise 10

Let the multireel file consist of a sequence of records distributed over several reels, with no restriction on where a run begins or ends relative to reel boundaries.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.3 Exercise 11

Let $T$ be a random AVL tree produced by Algorithm A from a uniformly random permutation of $\{1,\dots,n\}$, $n>6$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.1 Exercise 20

Let $C(N)=\log_b N$ for a constant $b>1$ to be determined.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.3 Exercise 24

Let $W(x)$ denote the number of internal nodes in the subtree rooted at $x$.

taocpmathematicsalgorithmsvolume-3math-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 8

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

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 6.2.2 Exercise 10

Let the incoming keys be $K_1, K_2, \ldots, K_n$, arriving in an arbitrary order.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2.4 Exercise 1

**Corrected Solution to Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.5 Exercise 2

Table 1 gives the following MIX running-time estimates for list-sorting methods: \begin{aligned} \text{List insertion:} \qquad &1.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.3.2 Exercise 19

Let $M(m,n)$ denote the minimum number of comparisons required to merge two increasing sequences of lengths $m$ and $n$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.2 Exercise 34

Let $p_1,\dots,p_r$ satisfy $p_i \ge 0$ and $\sum_{i=1}^r p_i = 1$, and let $n_i = p_i N$ with integers $n_i$ such that $\sum_{i=1}^r n_i = N$.

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

A sorting method is stable if whenever two records $R_a$ and $R_b$ satisfy $K_a = K_b$ and $R_a$ precedes $R_b$ in the input, then $R_a$ precedes $R_b$ in the output.

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

Let $K_m$ denote $K^{(p)}$, the number of sequences of length $m$ consisting of $0$’s and $1$’s that contain no $p$ consecutive $1$’s.

taocpmathematicsalgorithmsvolume-3math-medium
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.2 Exercise 22

Let $T = P+1$ and let $t_n$ denote the total number of runs in the perfect level-$n$ distribution for $T$ tapes, as in equation (6).

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.2.1 Exercise 7

Let $a_1 a_2 \dots a_n$ be a random permutation of ${1,2,\dots,n}$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.3 Exercise 33

Let (17) be written in its full binomial-convolution form as it appears in Section 6.

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