brain

tamnd's digital brain — notes, problems, research

43815 notes

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.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.2.3 Exercise 13

**Exercise 5.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 22

We work in the setting of Algorithm C, where each key $x$ is inserted into a singly linked chain for bucket $h(x)$ by _inserting at the head_.

taocpmathematicsalgorithmsvolume-3hard
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 5.2.4 Exercise 1

**Corrected Solution to Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.1 Exercise 11

The reviewer is correct: the proposed solution does not address the problem at all.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.4 Exercise 53

The error in the proposed solution occurs at the change of variables and the resulting failure to preserve the structure needed for an incomplete gamma representation.

taocpmathematicsalgorithmsvolume-3hm-medium
TAOCP 5.4.9 Exercise 9

Let $T$ be a full binary tree with $n$ leaves, and let $D(T)$ and $E(T)$ be the two weighted path functionals defined in Section 5.

taocpmathematicsalgorithmsvolume-3hm-research
TAOCP 5.3.2 Exercise 8

We construct a deterministic comparison algorithm and verify a uniform worst-case bound of $6$ comparisons.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.9 Exercise 8

We restart from the definition of the objective and avoid assuming any unverified identity between $E(T)$ and $D(T)$.

taocpmathematicsalgorithmsvolume-3research
TAOCP 5.4.1 Exercise 6

The issue is not merely tree degeneracy at $P=2$, but the fact that Algorithm R implicitly assumes the existence of at least one comparison.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 6.4 Exercise 1

The previous solution fails because it replaces MIX instruction semantics with an unsupported linear model and ignores control flow.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 15

Let the hash table contain $M$ locations and let $N$ be the number of keys currently stored.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.3.2 Exercise 6

The proof of Theorem K is carried out by verifying that a proposed closed form agrees with the values of the adversary functions $_M(m,n)$ defined by the recurrence inequalities coming from Strategies...

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.2.4 Exercise 3

Let $m=101$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.4 Exercise 9

A B-tree can be adapted to support retrieval by position in a linear list by augmenting each node with information about subtree sizes, so that navigation is driven by rank rather than key comparison.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.1 Exercise 19

Let a fixed permutation of the records be given, and let $\pi(i)\in{1,\dots,N}$ denote the position of record $R_i$ in the array.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.3.2 Exercise 1

We restart from the correct structural interpretation of $S'(k)$ as an optimal **merging-based sorting cost**, and we avoid assuming any fixed decomposition into prescribed sizes.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.5 Exercise 5

Let $R_1, R_2, \dots, R_N$ be a table of records with corresponding keys $K_1, K_2, \dots, K_N$.

taocpmathematicsalgorithmsvolume-3research
TAOCP 5.2.5 Exercise 8

Let the radix be $M$ and let keys be written as $(a_1,a_2,\dots,a_p)$ with digits $0 \le a_i < M$.

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

A multireel file consists of a finite sequence of reels, each reel being a sequential medium on which records are read and written in forward order, with a forced change of reel when an end is reached...

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 16

The previous solution fails because it tries to reduce structural equality of binary search trees to inorder equality and informal “locality” arguments.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.5 Exercise 2

Let $T=5$ and hence $P=4$.

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.1.4 Exercise 3

Let $P$ be the tableau corresponding to a permutation $a_1 a_2 \dots a_m$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.3.2 Exercise 14

We restart from a correct decision-tree formulation and remove the unverified state model.

taocpmathematicsalgorithmsvolume-3project
TAOCP 5.1.4 Exercise 2

For each entry $a_i$ of the permutation, let $t_i$ be the class defined in the text.

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.6 Exercise 10

Let $S$ be the total number of runs in the file.

taocpmathematicsalgorithmsvolume-3math-medium
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.2.3 Exercise 4

Let $I(T)$ denote the internal path length of a tree $T$, defined as the sum of the depths of all internal nodes of $T$, where the root has depth $0$ and each child increases depth by $1$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.3.3 Exercise 2

We give a clean decision-tree argument that avoids the gap in the previous solution and directly relates worst-case depths.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.3 Exercise 16

Patricia trees represent a set of strings by a compressed trie in which each branching decision is determined by inspecting selected character positions, and in which nodes are arranged so that every...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.3.4 Exercise 1

Let the input to the merge network be two sorted sequences of lengths $m=3$ and $n=5$: (x_1,x_2,x_3) \quad \text{and} \quad (y_1,y_2,y_3,y_4,y_5).

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.8 Exercise 2

From the definition in (3), the procedures `SORTOO`, `SORT11`, `SORT01`, and `SORT10` differ only by a swap of tape roles.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.3.3 Exercise 5

Let $n$ be the total number of distinct elements.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.2 Exercise 20

Let the search tree be built by inserting keys in the order $K_1, K_2, \dots, K_n$, where the access probabilities satisfy $p_1 > p_2 > \cdots > p_n.$ The structure of Algorithm $T$ depends only on ke...

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.4 Exercise 30

Let $a_1,\dots,a_n$ be the preferred parking positions, where each $a_j \in {1,\dots,n}$ and $n=m$.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 6.4 Exercise 61

The error in the previous solution is the assumption that column-wise uniformity of the permutations implies optimality of all coefficients $c_k$.

taocpmathematicsalgorithmsvolume-3math-research
TAOCP 6.3 Exercise 17

Let $B$ denote the binomial transform operator acting on sequences $x = (x_n)_{n \ge 0}$ by (Bx)_n = \sum_{k=0}^{n} \binom{n}{k} x_k .

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.3.2 Exercise 16

Let $H(m,n)$ denote the number of comparisons performed by Hwang and Lin’s binary merging algorithm when merging $A_1<\cdots<A_m$ with $B_1<\cdots<B_n$ under worst-case behavior.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.8 Exercise 1

Let the original order-$P$ bubble sort be defined as in Section 5.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.3 Exercise 4

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

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.4 Exercise 66

Assume an open addressing scheme using Algorithm L or Algorithm D.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.1 Exercise 14

The key issue is the conditioning of the truncation point.

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

Let $d$ be fixed.

taocpmathematicsalgorithmsvolume-3hm-hard
TAOCP 5.3.1 Exercise 8

We restart the argument from the correct structural relationship between comparison trees and comparison–exchange trees, and avoid any “locking” interpretation of swaps.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.2 Exercise 12

Let $Q$ be the node selected for deletion, chosen uniformly from the $N$ nodes of a binary search tree formed by random insertion of $N$ keys.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.1 Exercise 25

Let $a_k$ and $b_k$ denote the numbers of internal and external nodes on level $k$, respectively.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.1 Exercise 1

Let $l$ and $u$ be the current indices in Algorithm B (binary search on a sorted table $K_1 < \cdots < K_n$), with sentinels $K_0 = -\infty$ and $K_{n+1} = +\infty$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.3.2 Exercise 7

The original argument fails because it never establishes a real comparison between the two quantities $M(k+m,n)$ and $M(k,n)+M(m,n)$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.2 Exercise 14

The original argument fails because it assumes a uniform “shift” of depths along the entire search path from $x$ to the chosen replacement node.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.6 Exercise 5

Algorithm F forecasts the next input operation by examining the last records currently present in the active buffers.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.2 Exercise 48

Let $T_n$ denote the set of binary search trees on $n$ distinct keys, and consider the Markov process in which at each step an insertion of a random key and a deletion of a uniformly chosen node are p...

taocpmathematicsalgorithmsvolume-3
TAOCP 6.4 Exercise 63

Let the hash table have $M$ locations.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.2 Exercise 29

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

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

Let $T$ be the binary search tree shown in Fig.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.3 Exercise 32

We correct the proof by replacing the invalid greedy lemma with a precise structural argument based on inorder intervals.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.2.3 Exercise 12

Let $r$ denote the current odd integer under consideration and let $H$ be a priority queue keyed by the first unprocessed odd composite associated with each prime.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.3 Exercise 1

In Case 2 the symmetric order of the keys is determined by the in-order sequence of the subtrees: all keys in the left subtree of $A$ precede $\text{KEY}(A)$, all keys in the left subtree of $B$ that...

taocpmathematicsalgorithmsvolume-3simple
TAOCP 5.4.1 Exercise 21

The previous solution failed because it replaced the combinatorial snowplow construction with an ungrounded probabilistic model and used undefined parameter substitutions.

taocpmathematicsalgorithmsvolume-3hm-medium
TAOCP 6.3 Exercise 9

The original attempt fails mainly because it mixes abstract register notation with MIX conventions and omits the actual pointer manipulation required by Algorithm D.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.6 Exercise 13

The previous solution fails because it attempts to repair the situation by adding an external phase.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2.2 Exercise 1

Let $x = a_i$ and $y = a_j$ with $i < j$ and $x > y$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.2.5 Exercise 7

Algorithm R and radix exchange sorting both exploit the representation of keys as digit sequences and avoid direct key-to-key comparison.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.3.4 Exercise 5

The odd-even merge network is composed of two independent recursive merge networks, one acting on the odd subsequences and one acting on the even subsequences, followed by a single layer of comparison...

taocpmathematicsalgorithmsvolume-3
TAOCP 6.3 Exercise 43

Working

taocpmathematicsalgorithmsvolume-3hm-project
TAOCP 6.2.3 Exercise 19

Let $S$ be the root of a balanced binary tree in the sense of Section 6.

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

Let each initial run $i$ have weight $w_i$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.6 Exercise 14

The reviewer is correct that the previous response never engages with the actual mathematical content of equations (8), (9), and (10).

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.5 Exercise 81

At initialization $i \leftarrow 1$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.3.1 Exercise 5

The previous solution fails because it treats the problem as one of extracting information from a fixed probabilistic comparison outcome, whereas the task is a deterministic decision problem in the co...

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.1 Exercise 8

Let \Delta[j]=\left\lfloor \frac{N+2^{j-1}}{2^j}\right\rfloor,\qquad 1\le j\le k,\quad k=\lfloor \lg N\rfloor+2.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.4 Exercise 25

Equation (39) expresses the probability that $N$ distinct keys $K_1,\dots,K_N$ hash into $N$ distinct table positions when each key is assumed to be mapped independently and uniformly into a hash tabl...

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.2.4 Exercise 8

The error in the previous solution occurs at exactly one decisive point: the computation of m_k=\left\lfloor \frac{r_k}{2}\right\rfloor from the binary expansion of $N$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.9 Exercise 24

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

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 6.2.3 Exercise 27

Let a 2-3 tree be defined as in Section 6.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.9 Exercise 14

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

taocpmathematicsalgorithmsvolume-3project
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 6.2.2 Exercise 49

Let $T_n$ be a binary search tree formed by inserting $n$ distinct keys in random order, each of the $n!$ permutations equally likely, using Algorithm T of Section 6.

taocpmathematicsalgorithmsvolume-3hm-project
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 5.4.9 Exercise 6

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

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 43

Let $N$ denote the number of items stored.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.3 Exercise 28

A 2-3 tree is a rooted ordered tree in which every internal node has either two or three children and contains respectively one or two keys, and in which all external nodes occur at the same level.

taocpmathematicsalgorithmsvolume-3project
TAOCP 6.4 Exercise 72

Let $H$ be a matrix with $R$ rows and one column for every possible key $K$.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.2.3 Exercise 17

Let $T$ denote the balanced tree of Fig.

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

Let $S_M$ be the set of all permutations of $\{0,1,\dots,M-1\}$, and let $\mathbb{P}$ be a probability assignment on $S_M$ that is equivalent to uniform probing in the sense of Theorem U.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.2 Exercise 3

Start from the definition at the end of step D4: D[j] = a + A[j] - A[j+1], \qquad 1 \le j \le T, with $A[T+1]=0$.

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.1.4 Exercise 11

**Exercise 5.

taocpmathematicsalgorithmsvolume-3math-simple
TAOCP 6.2.2 Exercise 35

Let $p_{ij} = \Pr(X = x_i, Y = y_j)$, $p_i = \Pr(X = x_i) = \sum_j p_{ij}$, and $q_j = \Pr(Y = y_j) = \sum_i p_{ij}$.

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