brain

tamnd's digital brain — notes, problems, research

41641 notes

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

Working

taocpmathematicsalgorithmsvolume-3hm-project
TAOCP 5.4.1 Exercise 23

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

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.4 Exercise 10

Let N(a,b,c) denote the number of permutations of the multiset

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 6.4 Exercise 57

Let the table have size $M$, and let $n$ records be present, so exactly $M-n$ locations are empty.

taocpmathematicsalgorithmsvolume-3math-research
TAOCP 5.1.3 Exercise 11

**Exercise 5.

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

Let f_p(z)=z^p - z^{p-1}-\cdots-1.

taocpmathematicsalgorithmsvolume-3hm-medium
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.3.1 Exercise 2

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

taocpmathematicsalgorithmsvolume-3
TAOCP 5.1.3 Exercise 3

Using the binomial theorem, (1-1)^n=\sum_{k=0}^{n}\binom{n}{k}1^{\,n-k}(-1)^k =\sum_{k=0}^{n}\binom{n}{k}(-1)^k .

taocpmathematicsalgorithmsvolume-3
TAOCP 6.1 Exercise 21

Let $G_n$ be the $n$-cube with vertex set $\{0,1\}^n$.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.3.1 Exercise 4

The goal is to determine the sorted order of $n$ keys, knowing each key is either $0$ or $1$.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.2 Exercise 31

Let $K_a(n)$ denote the number of ordered (plane) rooted trees with $n$ nodes in which every leaf is at distance exactly $a$ from the root.

taocpmathematicsalgorithmsvolume-3math-medium
TAOCP 5.5 Exercise 81

At initialization $i \leftarrow 1$.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.1 Exercise 28

Let $T_0(x)=x*x$, $T_1(x)=x$, and for $n \ge 0$, T_{n+2}(x)=T_{n+1}(x) * T_n(x).

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

Let $s_0, s_1, \ldots, s_n$ be arbitrary distinct keys.

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 6

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

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

We repair the argument from the ground up and keep only valid structural facts about optimal BSTs.

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

The key issue is the conditioning of the truncation point.

taocpmathematicsalgorithmsvolume-3hm-medium
TAOCP 5.4.1 Exercise 12

Let $P$ be the number of external nodes of the loser tree and let $h$ be its height, so that every path from an external node to the root contains exactly $h$ internal nodes.

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

Yes.

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

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

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.1 Exercise 10

The flaw in the previous argument is the assumption that LOSER pointers are merely passive storage.

taocpmathematicsalgorithmsvolume-3hard
TAOCP 5.3.3 Exercise 5

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

taocpmathematicsalgorithmsvolume-3
TAOCP 5.3.3 Exercise 10

Solution to TAOCP 5.3.3 Exercise 10.

taocpmathematicsalgorithmsvolume-3math-research
TAOCP 5.3.2 Exercise 14

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

taocpmathematicsalgorithmsvolume-3project
TAOCP 5.2 Exercise 3

No.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.8 Exercise 3

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

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

The changes preserve correctness.

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

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

taocpmathematicsalgorithmsvolume-3
TAOCP 6.2.3 Exercise 7

Let $B_h$ denote the number of balanced trees of height $h$, and define $C_h = B_h + B_{h-1}$.

taocpmathematicsalgorithmsvolume-3
TAOCP 6.1 Exercise 17

Let a schedule be a permutation $a_1 a_2 \dots a_n$ of the jobs $1,2,\dots,n$.

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

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

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

Batcher’s merge-exchange method is not stable.

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.9 Exercise 11

Working

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

After Step 3 the current front keys of the four runs are $503,\ 170,\ 426,\ 612$ after the replacement of $154$ by $426$.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 6.3 Exercise 19

The expression in the prompt is clearly truncated, but the surviving fragment “$k>2$” together with the parameters $s>0$, $m>1$, and the cross-reference to Exercise 5.

taocpmathematicsalgorithmsvolume-3hm-medium
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 6.2.3 Exercise 10

The flaw in the previous argument is that it tried to _compute_ subtree validity and heights from the balance-factor sequence before establishing that a subtree actually exists.

taocpmathematicsalgorithmsvolume-3hard
TAOCP 5.4.2 Exercise 12

The flaw in the previous argument is not the linear algebraic part but the missing derivation of the transition rule from the definition of the perfect Fibonacci (perfect polyphase) distributions in (...

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

Algorithm D inserts keys one at a time.

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

Let $W_t(n)$ denote the worst-case number of comparisons required by any comparison-based algorithm for the structure defined in the exercise.

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

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

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

Let the hash table have $M$ locations.

taocpmathematicsalgorithmsvolume-3math-medium
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 68

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

taocpmathematicsalgorithmsvolume-3
TAOCP 5.4.2 Exercise 13

Working

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
TAOCP 6.4 Exercise 55

The previous argument failed at the very start because it assumed a functional equation without deriving the Schay–Spruth state recursion.

taocpmathematicsalgorithmsvolume-3hm-project
TAOCP 6.2.3 Exercise 14

Algorithms 6.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 6.3 Exercise 2

Let $K$ be the search argument, and assume it is represented as a sequence of characters ending with the blank symbol used in Algorithm T.

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.2 Exercise 1

Let $A$ denote the null pointer used in Algorithm T.

taocpmathematicsalgorithmsvolume-3simple
TAOCP 6.2.1 Exercise 2

We analyze the modified versions of Algorithm B under the assumption that the table is sorted strictly increasing, k_1 < k_2 < \cdots < k_n, and that the key $K$ is present, with unique index $p$ such...

taocpmathematicsalgorithmsvolume-3medium
TAOCP 6.2.3 Exercise 12

Let $T_7$ denote a balanced binary tree with $7$ internal nodes.

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

Let $M$ be the range of hash values $\{0,1,\dots,M-1\}$.

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

The previous solution fails because it replaces Carroll’s actual tournament mechanism with an invented dominance-based rule and then reasons about that artificial system.

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

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

taocpmathematicsalgorithmsvolume-3medium
TAOCP 5.3.2 Exercise 21

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

taocpmathematicsalgorithmsvolume-3math-research
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.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 5.2.2 Exercise 5

Let $b_1 b_2 \dots b_n$ be the inversion table of the permutation $a_1 a_2 \dots a_n$.

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

Let $d$ be fixed.

taocpmathematicsalgorithmsvolume-3hm-hard
TAOCP 6.2.1 Exercise 18

The reviewer is correct that the previous solution replaced Program F’s frequency model with an unjustified uniform-visitation assumption.

taocpmathematicsalgorithmsvolume-3math-hard
TAOCP 5.4.2 Exercise 25

We restart from the correct structure of a 4-tape polyphase merge.

taocpmathematicsalgorithmsvolume-3medium