TAOCP 5.4.4 Exercise 6
The tree representation (8) illustrates the balanced merge on four tapes with eight initial runs, as summarized in the tableau of the section.
Section 5.4.4: Reading Tape Backwards
Exercise 6. [07] What is the vector representation of the merge pattern whose tree representation is (8)?
Verified: no
Solve time: 3m34s
The tree representation (8) illustrates the balanced merge on four tapes with eight initial runs, as summarized in the tableau of the section. The merge steps, in chronological order, are:
- Merge one run from T1 and one from T2 → T3
- Merge one run from T1 and one from T2 → T4
- Merge one run from T1 and one from T2 → T3
- Merge one run from T1 and one from T2 → T4
- Merge one run from T3 and one from T4 → T1
- Merge one run from T3 and one from T4 → T2
- Merge one run from T1 and one from T2 → T3
The final sorted output resides on tape 3. According to the definition, the vector representation is the sequence ((y^{(m)}\ldots y^{(1)}y^{(0)})) where (y^{(i)}) corresponds to the (i)th-last merge step, with (+1) for input tapes, (-1) for the output tape, and (0) otherwise; (y^{(0)}) is the unit vector for the final output tape. Reversing the chronological list gives the merge vectors from first to last:
[ \begin{aligned} y^{(7)} &= (1,1,-1,0) \ y^{(6)} &= (1,1,0,-1) \ y^{(5)} &= (1,1,-1,0) \ y^{(4)} &= (1,1,0,-1) \ y^{(3)} &= (-1,0,1,1) \ y^{(2)} &= (0,-1,1,1) \ y^{(1)} &= (1,1,-1,0) \ y^{(0)} &= (0,0,1,0) \end{aligned} ]
\boxed{(1,1,-1,0),\ (1,1,0,-1),\ (1,1,-1,0),\ (1,1,0,-1),\ (-1,0,1,1),\ (0,-1,1,1),\ (1,1,-1,0),\ (0,0,1,0)} ∎