brain

tamnd's digital brain — notes, problems, research

43815 notes

TAOCP 6.2.3 Exercise 31

The previous construction fails because it relies on a representation (a forest of perfect trees) that is not closed under splitting.

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

Let the two sorted sequences have lengths $m$ and $n$.

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

Let $T=(V,E)$ be a finite tree with positive edge lengths $\ell(e)>0$ for $e\in E$.

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

Start by separating what must be proved from what was previously assumed without justification.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.6 Exercise 3

Solution to TAOCP 5.4.6 Exercise 3.

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.2.2 Exercise 15

We reanalyse the process without symmetry shortcuts that are not grounded in the algorithm, and we reduce everything to an explicit counting over induced insertion orders on the final 3-key tree.

taocpmathematicsalgorithmsvolume-3medium
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.2.2 Exercise 40

Let $T_n$ be a binary search tree built from a uniformly random permutation of $n$ distinct keys, so every BST shape consistent with in-order orderings occurs with the standard BST probability model.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.3.2 Exercise 15

We compute $\left\lfloor \lg(n/m) \right\rfloor$ for $n>m$ by characterizing it as the unique integer $k \ge 0$ such that $m \cdot 2^k \le n < m \cdot 2^{k+1}.$ This reformulation eliminates division...

taocpmathematicsalgorithmsvolume-3simple
TAOCP 5.1.3 Exercise 9

Let a **run** in a permutation be a maximal increasing sequence of consecutive elements.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.4.8 Exercise 3

Let $N$ records reside initially on tape $T_0$.

taocpmathematicsalgorithmsvolume-3project
TAOCP 6.1 Exercise 3

We restart the analysis from the instruction-level behavior of the MIX program.

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

Algorithm 5.

taocpmathematicsalgorithmsvolume-3medium
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.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 5.4.9 Exercise 13

Let $T$ range over admissible merge patterns for $n$ runs, where each internal node has arity at most $8$, and cost is the weighted external path length C(T)=\sum_{i=1}^n w_i d_i.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.2.2 Exercise 4

The flaw in the previous solution is the attempt to characterize the event using the original suffix $R_2,\dots,R_n$ without tracking how a bubble sort pass changes the array after the first compariso...

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

Let v_n = (a_n, b_n, c_n, d_n, e_n) denote the six-tape cascade numbers at level $n$, with initial condition

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.7 Exercise 4

The previous solution failed because it treated “group sizes” as independent subproblems and implicitly allowed arbitrary arity patterns.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.6 Exercise 1

Let $L = 23{,}000{,}000$.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.1.2 Exercise 10

**Solution to Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.2.2 Exercise 6

Algorithm M (as used in Section 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.3.2 Exercise 17

We now reconstruct equation (21) from the standard context of Section 5.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.2 Exercise 27

The reviewer’s diagnosis is correct: the previous proof implicitly replaced each tape by a globally sorted sequence, which is false.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.4.3 Exercise 10

Let $A_n, B_n, C_n, D_n, E_n$ be the cascade sequences of Section 5.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.3 Exercise 1

In a tree, leaves are nodes with no descendants.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.2.3 Exercise 10

Let the standard heapsort “sift-down” step be denoted by the variables of Algorithm H, where a key at position $k$ is moved downward by repeatedly comparing it with its children at $2k$ and $2k+1$, an...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2.3 Exercise 5

The previous solution correctly implemented a left-to-right maximum search, but it never established the _inter-iteration structure_ that makes the modification useful.

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

Let B_h := B_h(1), \qquad h \ge 0, and assume the standard recurrence for height-balanced binary trees:

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.2 Exercise 43

Phase 2 constructs the binary tree from the sequence produced by phase 1, which is a linear list of leaves (or partial trees) in symmetric order.

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

The error in the previous solution is structural: it used an incorrect recurrence for the modified external path length and then built an unnecessary vector-valued dynamic program on top of it.

taocpmathematicsalgorithmsvolume-3math-project
TAOCP 5.2.1 Exercise 13

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

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.6 Exercise 2

The key point is not that File 2 is “unused”, but how Algorithm B assigns and clears buffers when a file changes role and when the first output block is actually produced.

taocpmathematicsalgorithmsvolume-3simple
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 6.2.1 Exercise 3

The statement “What searching method corresponds to the tree ?

taocpmathematicsalgorithmsvolume-3simple
TAOCP 5.4.9 Exercise 5

Let $T$ be a rooted tree representing a merge pattern as in Theorem K, with leaves carrying weights $w_1,\dots,w_n$, and let the external path length be E(T)=\sum_{i=1}^n w_i d_i, where $d_i$ is the l...

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.4.1 Exercise 8

Algorithm R relies on a distinguished key value $oo$ such that for every actual key $K$, the relation $K < oo$ holds in the ordering used by the selection tree.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.4 Exercise 4

We restart from the standard Bayer–McCreight B-tree model and make explicit the structural object being modified.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2 Exercise 4

After Program C has terminated, the value $\mathrm{COUNT}[i]+1$ is the final position of record $R_i$.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.1 Exercise 21

Let the keys be K_1<K_2<\cdots<K_{10}, and let the unsuccessful-search intervals (gaps) be

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 5.4.3 Exercise 9

We restart from the cascade structure in Algorithm C and derive equation (14) in a way that correctly matches the backward extension construction and applies Lagrange inversion in its valid form.

taocpmathematicsalgorithmsvolume-3hm-hard
TAOCP 5.4.2 Exercise 2

The previous solution failed because it replaced Algorithm D with an unproved “Fibonacci level” abstraction and then reasoned about dummy runs in that model.

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 5.4.1 Exercise 5

A selection tree used for replacement selection represents $P$ external nodes as the leaves of a complete binary tree, with internal nodes storing comparison results along the path to the root.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.3 Exercise 20

We consider binary trees in which every node $P$ satisfies the constraint B(P) = h(R(P)) - h(L(P)) \in \{0,1\}, that is,

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

The reviewer is correct that the original argument fails because it treats the modified algorithm as if it follows the same step-by-step state evolution as the original.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.2.4 Exercise 2

Let $X$ be the number of times step M2 is executed when merging $x_1,\dots,x_m$ with $y_1,\dots,y_n$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.3.2 Exercise 3

We restart from the definitions of the two quantities in Knuth’s merging model.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.3 Exercise 18

Unusual activity has been detected from your device.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2.1 Exercise 12

A 2-ordered permutation $a_1a_2\cdots a_n$ satisfies a_i<a_{i+2}\qquad (1\le i\le n-2).

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.5 Exercise 1

The methods discussed in this chapter are unified by viewing external sorting as the problem of constructing initial sorted runs and then combining them by successive multiway merges until a single or...

taocpmathematicsalgorithmsvolume-3simple
TAOCP 5.2.3 Exercise 9

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

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.2 Exercise 18

Let $T > 3$ be fixed and set $P = T - 1$.

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

We restart from the definition of marking in the TAOCP model and avoid any auxiliary pipeline assumptions.

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

In a successful sequential search through $N$ records, every position $i \in {1,\dots,N}$ occurs with probability $1/N$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.1 Exercise 3

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

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.3.2 Exercise 21

Let $M(m,n)$ be Knuth’s function from Section 5.

taocpmathematicsalgorithmsvolume-3math-research
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.3.2 Exercise 10

Working

taocpmathematicsalgorithmsvolume-3hard
TAOCP 5.2.4 Exercise 7

A correct analysis must stay inside the structural model of Program L (natural two-way merge on runs), interpret the quantities exactly as defined in Knuth’s framework, and then specialize to the conc...

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.3 Exercise 44

Let $\Sigma$ be an ordered alphabet corresponding to the $M$ characters used in Section 6.

taocpmathematicsalgorithmsvolume-3hard
TAOCP 6.3 Exercise 18

Let the coupled recurrences (4) and (5) be written in vector form as \mathbf{z}_n = \begin{pmatrix} x_n\\ y_n

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.3 Exercise 20

We correct the analysis by keeping the Poissonized occupancy framework but fixing the asymptotic accuracy statements and making the sequential-search contribution explicit.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.1 Exercise 9

Let $p_k$ be probabilities on ${1,2,\dots,N}$ with $\sum_{k=1}^N p_k=1$.

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

The previous argument fails because it treats comparison sharing and adversary accounting heuristically, and it never establishes a valid cost model for selecting the two boundary order statistics or...

taocpmathematicsalgorithmsvolume-3hm-project
TAOCP 6.1 Exercise 10

Let $p_1, p_2, \dots, p_N$ be the probabilities that the argument equals $K_1, K_2, \dots, K_N$, with $\sum_{i=1}^N p_i = 1$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.2.2 Exercise 23

We restart from the correct objective formulation and avoid any local “node-only” rotation arguments.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.1.3 Exercise 6

The mistake is that Mr.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.2.2 Exercise 3

Yes, Algorithm B is a stable sorting algorithm.

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

The reviewer’s critique is correct: the previous response failed because it never instantiated the computation on the actual data.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.1.2 Exercise 11

**Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.3 Exercise 39

We construct a fully rigorous solution by cleanly separating the structural lemma from the contraction argument, avoiding informal swapping arguments.

taocpmathematicsalgorithmsvolume-3math-project
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 4

Let $A$ be an optimal comparison-based algorithm that finds the third largest element, and let its worst-case number of comparisons be $V_3(n)$.

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

Let $T \ge 4$ tapes be available.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.3 Exercise 3

Let each key $x$ in the set of 31 words have frequency $f(x)$ as given by Fig.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.2.3 Exercise 7

After 14 outputs, all but two elements have been replaced by $-\infty$ in the tournament structure of Fig.

taocpmathematicsalgorithmsvolume-3