brain

tamnd's digital brain — notes, problems, research

43815 notes

TAOCP 5.3.3 Exercise 6

We give a complete proof consisting of a tight upper bound (algorithm) and a correct adversary lower bound.

taocpmathematicsalgorithmsvolume-3medium
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 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.4.2 Exercise 29

The previous argument fails because it replaces the actual TAOCP merge-until-empty mechanism with a two-number Euclidean subtraction process.

taocpmathematicsalgorithmsvolume-3math-research
TAOCP 5.3.2 Exercise 9

We construct a single, explicit decision tree of comparisons whose worst-case depth is at most 7.

taocpmathematicsalgorithmsvolume-3hard
TAOCP 5.4.3 Exercise 8

Let $T=6$ in the notation of the section, and write X_n = (A_n, B_n, C_n, D_n, E_n)^T .

taocpmathematicsalgorithmsvolume-3hm-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.2.2 Exercise 9

The critical flaw in the previous solution is that it never performs the required empirical measurement.

taocpmathematicsalgorithmsvolume-3project
TAOCP 5.1.4 Exercise 1

Let \begin{pmatrix} a_1&a_2&\cdots&a_9\\ b_1&b_2&\cdots&b_9 \end{pmatrix}

taocpmathematicsalgorithmsvolume-3
TAOCP 6.3 Exercise 21

Let $M \ge 2$ and consider a random $M$-ary trie built from $N$ keys, where each digit of each key is independently uniformly distributed in ${0,1,\dots,M-1}$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.2 Exercise 15

The statement concerns three families of quantities $X_n(m)$, $Y_n(m)$, $S_n(m)$, together with a primed variant $X'_{n-1}(m)$.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 6.4 Exercise 67

Linear probing with a full table and distinct home addresses is not governed by “cyclic inversion geometry” in the way the previous solution assumed.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 6.2.2 Exercise 26

Let the weights $(p_1,\ldots,p_{n-1}; q_0,\ldots,q_{n-1})$ be fixed nonnegative real numbers, and impose the constraint p_n + q_n = Z, where $Z$ is a fixed positive constant.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.3.3 Exercise 12

Let $o$ be the integer satisfying $2^o < \frac{n-1}{4} < 2^{o+1}$, equivalently $4\cdot 2^o < n-1 < 5\cdot 2^o.$ Write $n-1 = 4\cdot 2^o + r,\qquad 0 < r < 2^o.$ Form four disjoint knockout trees $T_1...

taocpmathematicsalgorithmsvolume-3medium
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.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 6.2.3 Exercise 16

The previous submission fails for one precise reason: it never instantiates the actual tree of Fig.

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

A $P$-way merge produces one output block per unit of time, where the time to write a block equals the time to read a block.

taocpmathematicsalgorithmsvolume-3hard
TAOCP 5.2.3 Exercise 14

Exercise 16 describes the standard heap insertion operation: append the new key at the end of the heap and repeatedly interchange it with its parent until the heap property is restored.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.1 Exercise 16

The previous solution fails because it replaces the **online heap constraint system** of replacement selection with a global ordering argument.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.2.2 Exercise 5

Let $T$ be the binary search tree obtained when the keys are inserted in the order \text{CAPRICORN},\ \text{AQUARIUS},\ \text{ARIES},\ \text{TAURUS},\ \text{CANCER},\ \text{SCORPIO},\ \text{PISCES},\...

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.1.3 Exercise 1

**Exercise 5.

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

The computation performed by Program L does not fail arithmetically when $K = 0$.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 5.3.3 Exercise 13

We restart the argument from the definition used in this section of TAOCP, where $V_r(n)$ denotes the generalized power sum V_r(n) = \sum_{k=1}^n k^r, extended to complex $r$ by analytic continuation.

taocpmathematicsalgorithmsvolume-3math-research
TAOCP 6.1 Exercise 6

The previous solution fails because it violates MIX syntax (memory increment and malformed immediate comparisons) and because it does not specify a legitimate instruction-level control structure tied...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.6 Exercise 12

Six tapes are partitioned into three logical pairs.

taocpmathematicsalgorithmsvolume-3project
TAOCP 5.2 Exercise 3

No.

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

Table 1 in Section 5.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 5.4.1 Exercise 28

The key difficulty is not comparison but **storage lifetime**: a variable-length record must remain accessible through its descriptor for as long as it may still reside in the selection tree.

taocpmathematicsalgorithmsvolume-3medium
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 5.3.4 Exercise 2

Let $n$ be fixed and consider Pratt’s sorting network constructed from all 3-smooth numbers d = 2^i 3^j \le n.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.1 Exercise 29

Let $A_i = K_i$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.3 Exercise 10

Let the keys be $n$-bit binary numbers.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.1 Exercise 13

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

taocpmathematicsalgorithmsvolume-3simple
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.4 Exercise 71

Let $M$ denote the number of hash addresses and let $N$ denote the number of keys stored, with load factor $\alpha = \frac{N}{M}.$ Algorithm C is the separate chaining method described in Section 6.

taocpmathematicsalgorithmsvolume-3project
TAOCP 5.4.1 Exercise 2

Figure 63 is a loser tree in which each internal node stores the loser of the comparison, and the root contains the current champion.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 5.2.4 Exercise 3

The modification introduces an additional equality case in the comparison step of Algorithm M so that records from the first file are omitted whenever their keys also occur in the second file.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.1 Exercise 23

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

taocpmathematicsalgorithmsvolume-3
TAOCP 6.3 Exercise 11

Algorithm 6.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2.3 Exercise 3

The previous solution failed because it used unsupported structural claims about cycles and an undefined “charging” argument.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.2.4 Exercise 4

Let the records be stored in three contiguous segments of $N$ locations each, denoted $A_1,\ldots,A_N$, $B_1,\ldots,B_N$, and $C_1,\ldots,C_N$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.3 Exercise 7

Let $X_n$ denote the number of descents in a random permutation of ${1,2,\dots,n}$.

taocpmathematicsalgorithmsvolume-3hm-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.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 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.4 Exercise 14

The previous solution fails because it replaces the problem with a partitioned memory model.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.2 Exercise 8

Let $N_m^{(p)}$ denote the number of ordered representations of $m$ as a sum of integers from $\{1,2,\dots,p\}$.

taocpmathematicsalgorithmsvolume-3math-medium
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.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.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 6.4 Exercise 47

Let the table have size $M$, with $n$ stored keys and load factor $\alpha=n/M$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.1 Exercise 15

Let $T_k$ denote the Fibonacci tree of order $k$.

taocpmathematicsalgorithmsvolume-3math-medium
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
TAOCP 5.4.1 Exercise 18

Let the output of Algorithm R be the sequence of records obtained from the input file, with each record carrying an extended key $(S,K)$, where $S$ is the run number assigned during replacement select...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.3 Exercise 40

The failure of the original solution is the artificial reduction to a fixed window $t_0,\dots,t_{2N-1}$.

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 6.3 Exercise 8

Algorithm D maintains two variables during a descent in a digital search tree: $K$, the working copy of the search argument whose leading digit (or bit) determines the branching, and $K'$, a preserved...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.6 Exercise 9

The previous solution fails because it never uses the actual structure of Chart A, and therefore never computes the polyphase schedule or I/O count for $T=6$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 60

Let $M$ be the table size and let $n$ keys be stored, with load factor $\alpha = \frac{n}{M}.$ A single-hashing scheme assigns to each key $K$ a home address $h(K)\in{0,\dots,M-1}$, and associates wit...

taocpmathematicsalgorithmsvolume-3math-research
TAOCP 5.4.1 Exercise 17

Let the input keys satisfy $K_1 > K_2 > \cdots > K_N.$ Algorithm R initializes a selection tree with the first $P$ records.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.1.3 Exercise 8

**Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.1 Exercise 10

We restart from the definition of Algorithm C as the binary search procedure on an ordered table $A[1],\dots,A[N]$, using repeated halving of the interval of possible locations of the search key $K$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.3 Exercise 25

Let $T$ be a binary search tree in which every node $x$ stores a key and a weight $w(x) = 1 + w(\mathrm{LLINK}(x)) + w(\mathrm{RLINK}(x)),$ where missing subtrees have weight $0$.

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

Let $b_j$ be the number of external nodes at level $j$.

taocpmathematicsalgorithmsvolume-3math-medium
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 5.4.9 Exercise 25

The correct way to rework the example is to stay inside TAOCP’s randomized striping model: each run is striped across the $Q$ disks by a fixed permutation of disk numbers, and successive blocks of a r...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2.5 Exercise 1

The distribution sort of Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.3 Exercise 5

Let V_n = (A_n, b_n, c_n, d_n, e_n).

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.3.3 Exercise 16

A corrected solution is given below.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.3.4 Exercise 3

Apply equation (5) twice, first with $(m,n)=(m,m-1)$ and then with $(m,n)=(m,m)$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.2 Exercise 9

**9.

taocpmathematicsalgorithmsvolume-3hard
TAOCP 5.1.2 Exercise 8

Stopped thinking

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.1.2 Exercise 6

**Solution to Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.2 Exercise 7

Let the six admissible column types in (19) be \binom{b}{a},\quad \binom{c}{a},\quad \binom{a}{b},\quad \binom{c}{b},\quad \binom{a}{c},\quad \binom{b}{c},

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.2 Exercise 5

Condition (b) must exclude the case $x=y$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.2 Exercise 3

No.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.2 Exercise 4

If $d < c < b < a$, the canonical factorization of (12) is obtained by reversing the order of the letters in each cycle of the factorization given in (17).

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.2 Exercise 2

Using the definition of intercalation, we write \beta=\text{bddad} \qquad\Longrightarrow\qquad \begin{pmatrix} a&b&d&d&d\\

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.2 Exercise 1

False.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.1 Exercise 4

**Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.1 Exercise 1

Let the permutation be written in one-line form $a_1 a_2 \cdots a_9$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.1 Exercise 2

**Corrected Solution for Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.1 Exercise 3

Let $p_i$ denote the position of the element $i$ in the permutation, so that $a_{p_i}=i$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1 Exercise 3

Store the permutation in an array $P$ such that $P(j)$ is the position of $j$ in the permutation.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1 Exercise 1

Let the inversion table of a permutation $a_1a_2\cdots a_n$ be the sequence $b_1b_2\cdots b_n$, where $b_i$ is the number of entries greater than $i$ that occur to the left of $i$ in the permutation.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1 Exercise 2

Let the Josephus elimination process produce the sequence $x_1,x_2,\dots,x_n$, where $x_k$ is the label removed at step $k$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5 Exercise 5

Let each catalog card be considered as a record $R_j$ with a key $K_j$ that reflects the text of the card, including author, title, and date information.

taocpmathematicsalgorithmsvolume-3research
TAOCP 5 Exercise 2

The reviewer is correct.

taocpmathematicsalgorithmsvolume-3
TAOCP 5 Exercise 1

**Corrected Solution.

taocpmathematicsalgorithmsvolume-3
TAOCP 5 Exercise 4

Our systems have detected unusual activity coming from your system.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 4.7 Exercise 28

**Exercise 4.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.7 Exercise 26

The statement as printed cannot be correct, since the hypothesis \[ V(z)=U(V(z)) \] makes the additional condition about the coefficients of \(U(V(z))\) vacuous.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.7 Exercise 27

**Exercise 4.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.7 Exercise 25

Let U(z) = z + U_k z^k + U_{k+1} z^{k+1} + \cdots, \qquad k \ge 2, \quad U_k \ne 0, and

taocpmathematicsalgorithmsvolume-1math-medium