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...
Section 5.4.9: Disks and Drums
Exercise 25. [23] [23] Rework the text’s example of randomized striping for the case Q = 3 instead of Q = 4. What buffer contents would occur in place of (24)?
Verified: no
Solve time: 3m30s
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 run follow that permutation cyclically. The buffer at any moment contains the next unread block available on each disk, hence one block per disk.
For $Q=3$, we mirror the structure of the text’s $Q=4$ illustration by using three runs $A,B,C$ and three disks $0,1,2$, with the same “cyclic shift” family of permutations used in the example.
1. Striping model for $Q=3$
Let the striping permutations be
- Run $A$: $j \mapsto j \bmod 3$
- Run $B$: $j \mapsto (j+1) \bmod 3$
- Run $C$: $j \mapsto (j+2) \bmod 3$
Thus block $j$ of each run is stored on:
$$ \begin{aligned} A_j &\to \text{disk } j,\ B_j &\to \text{disk } (j+1)\bmod 3,\ C_j &\to \text{disk } (j+2)\bmod 3. \end{aligned} $$
At any moment, each disk contributes the next unread block currently residing on it.
2. Initial buffer state
For $j=0$:
- $A_0 \to 0$
- $B_0 \to 1$
- $C_0 \to 2$
So the buffer (ordered by disk $0,1,2$) is
$$ (A_0,; B_0,; C_0). $$
3. First transition
After one merge step, one block has been taken from each disk, so each run advances from block $0$ to block $1$. The new blocks are placed according to the same striping:
- $A_1 \to 1$
- $B_1 \to 2$
- $C_1 \to 0$
Hence the buffer becomes
$$ (C_1,; A_1,; B_1). $$
4. Second transition
Advance again to block $2$:
- $A_2 \to 2$
- $B_2 \to 0$
- $C_2 \to 1$
So the buffer is
$$ (B_2,; C_2,; A_2). $$
5. Third transition
Advance to block $3$:
- $A_3 \to 0$
- $B_3 \to 1$
- $C_3 \to 2$
So the buffer returns to
$$ (A_3,; B_3,; C_3), $$
which has the same cyclic structure as the initial state.
6. Replacement for (24)
Therefore, in place of (24), the buffer contents for $Q=3$ are the repeating cycle
$$ \boxed{ (A_0,B_0,C_0),; (C_1,A_1,B_1),; (B_2,C_2,A_2),; (A_3,B_3,C_3) } $$
and then the pattern repeats with period $3$ in the disk permutation structure.
7. Conclusion
For $Q=3$, randomized striping produces a deterministic cyclic rotation of which run appears on which disk at each step. The buffer states are not arbitrary Latin-square guesses but arise directly from how each run’s next block migrates across disks under its fixed striping permutation.