brain

tamnd's digital brain — notes, problems, research

41265 notes

TAOCP 4.2.4 Exercise 16

Let $P_1(n)\in{0,1}$ for $n\ge 1$.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 4.2.4 Exercise 15

Let $U=10^aX$, $V=10^bY$, where $X,Y\in[1,10)$ are independent and satisfy Benford’s law on $[1,10)$, i.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 4.2.4 Exercise 12

Work in logarithmic coordinates where the structure of floating-point multiplication becomes a probability-preserving convolution, and the abnormality becomes a supremum norm distance from the constan...

taocpmathematicsalgorithmsvolume-1hm-medium
CF 104664D - Noodling with Knights

We are given a square chessboard of size $N times N$, where squares are indexed by integer coordinates. A single knight starts on one square and we want to know the minimum number of legal knight moves needed to reach a target square.

codeforcescompetitive-programming
TAOCP 3.4.1 Exercise 32

Let $X$ and $Y$ be independent exponential deviates with mean $1$, so their joint density is $f_{X,Y}(x,y)=e^{-(x+y)}, \qquad x>0,\ y>0.$ The goal in each part is to show that the transformed pair $(X...

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 4.2.4 Exercise 14

Let U=b^{e_u}f_u,\qquad V=b^{e_v}f_v, where $1/b \le f_u,f_v < 1$.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 4.2.4 Exercise 13

Let $X$ and $Y$ denote the fraction parts of the two normalized floating point operands.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 3.3.3 Exercise 7

Let $h,k$ be positive integers with $\gcd(h,k)=1$.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.2.4 Exercise 11

Let $U>0$ be a random variable whose distribution satisfies the logarithmic law in base $10$.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 4.2.4 Exercise 10

The previous argument fails because it replaces the scalar asymptotic relation with an unrelated functional and spectral construction.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 4.3.1 Exercise 17

Let $V = (v_{n-1}\ldots v_0)_b$ be the divisor and let $R$ be the partial remainder at the moment the quotient digit $q$ is being determined in Knuth’s division algorithm (Algorithm D, Fig.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.4 Exercise 9

Let Eq.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 4.2.4 Exercise 7

Let $F(u)$ be a distribution function on $(0,\infty)$, and define, for each integer $b \ge 2$ and each $r \in [1,b]$, p_b(r)=\sum_{m=-\infty}^{\infty}\bigl(F(b^m r)-F(b^m)\bigr).

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 6.5 Exercise 16

Let $(V,\mathcal{B})$ be a Steiner triple system of order $v$, so each block $B \in \mathcal{B}$ has $|B|=3$ and every 2-element subset of $V$ lies in exactly one block.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 75

Let ${h_i}_{i=1}^R$ be independent random functions, each mapping the set of keys into ${0,1,\dots,M-1}$, and each value $h_i(K)$ is uniformly distributed over ${0,1,\dots,M-1}$ for every fixed key $K...

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.5 Exercise 2

Let the eight records be identified with binary triples 000,001,010,011,100,101,110,111.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.5 Exercise 10

Let a Kirkman triple system of order $v$ consist of $v+1$ objects $\{x_0,x_1,\dots,x_v\}$ and a family of triples such that every unordered pair of distinct objects occurs in exactly one triple, excep...

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.4 Exercise 77

We address the two failures in the original argument: 1.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.5 Exercise 13

Let $m = 2n$ and let $V = \mathbb{F}_2^m$, so $|V| = 2^m = 4^n$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.5 Exercise 14

The three structures all support dynamic sets of points in the plane, but they differ in what is structurally invariant.

taocpmathematicsalgorithmsvolume-3hard
TAOCP 6.5 Exercise 4

We restart from a correct event decomposition and avoid any use of the flawed distribution of $Q$.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.5 Exercise 8

A correct solution requires fixing the structural error in the treatment of the interaction between $S_0$ and $S_1$, and then proving that the minimizer has enough regularity (lexicographic initial se...

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.5 Exercise 3

The previous attempt failed because it replaced the signature analysis required by Table 2 with informal guesses.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.5 Exercise 12

Let $X=\{x_i,\bar x_i\mid i\in\mathbb Z_7\}$.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.5 Exercise 5

Let a composite file consist of two disjoint bit fields of lengths $m_1$ and $m_2$, so that $m = m_1 + m_2$.

taocpmathematicsalgorithmsvolume-3project
TAOCP 6.4 Exercise 78

Let $w>m>0$, $L=2^{w-m}$, and work modulo $2^w$.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 6.5 Exercise 11

A complemented triple system of order $v$ can be reformulated as a decomposition of the edge set of a graph on $2v$ vertices into triples (triangles) with the following structure.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.5 Exercise 19

The error in the previous solution comes from treating ABD(8,5) as if query elements were randomly scattered across rows.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.5 Exercise 9

Let the point set be $V = {0,1,2}^n$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.5 Exercise 15

The original proof fails because it attempts to collapse the search to a single decoded bucket.

taocpmathematicsalgorithmsvolume-3hm-hard
TAOCP 6.4 Exercise 76

Let a key $K$ be a variable-length sequence $K = (x_0, x_1, \dots, x_{\ell-1}),$ where each $x_i$ is an integer digit in ${0,1,\dots,r-1}$, and $\ell \ge 0$ depends on $K$.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.5 Exercise 7

The fundamental issue in the proposed solution is not computational but logical: it replaces the given combinatorial specification with an invented complete function.

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

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

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 68

Let $S_N = d_1 + d_2 + \cdots + d_N$.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.3 Exercise 21

The previous solution fails because it introduces unnecessary hierarchical structure that does not preserve the global constraint from Exercise 5.

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

Algorithm C still works if $i$ varies from $2$ up to $N$ in step C2 instead of from $N$ down to $2$, because the comparisons made in step C4 depend only on the relative ordering of $K_i$ and $K_j$, no...

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

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

taocpmathematicsalgorithmsvolume-3project
TAOCP 6.2.3 Exercise 27

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

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

The reviewer is correct that the original attempt destroys the essential feature of TAOCP §5.

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

Let $N$ keys be stored in an $M$-ary trie under the uniform random model in which each digit of each key is independently uniformly distributed in ${0,1,\dots,M-1}$.

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

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

taocpmathematicsalgorithmsvolume-3simple
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 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 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.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.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.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.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 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 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 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.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 5.1.3 Exercise 8

**Exercise 5.

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

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

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.4 Exercise 16

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

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

**Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.4 Exercise 66

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

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

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

taocpmathematicsalgorithmsvolume-3hm-medium
TAOCP 6.4 Exercise 64

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

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

The distribution sort of Exercise 5.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.2 Exercise 28

Let there be $T=6$ tapes, so $P=5$ input tapes and one output tape.

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

We restart from the actual structure of the defining equation (15) and avoid introducing any artificial kernel.

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

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

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

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

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

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

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

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

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

Let a weight-balanced tree be a binary tree in which there exists a fixed constant $0 < \alpha \le \tfrac{1}{2}$ such that for every internal node $v$ with subtree size $n(v)$, its left and right subt...

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.4.9 Exercise 31

The previous solution fails because it never reconstructs the _actual performance quantity in TAOCP’s striping model_.

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

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

taocpmathematicsalgorithmsvolume-3medium