Problem solved in full
-
The Burrows–Wheeler transform of "banana$" with all seven rotations sorted 5 steps
Find the Burrows–Wheeler transform of "banana$" and then decide whether anything has been compressed. This is the BWT output step: sentinel appended, all seven rotations sorted, last column read off.
-
The sentinel is appended before anything else happens. Because $ sorts before every letter and appears exactly once, no two rotations can compare equal, so the sort has a single unambiguous answer.
-
Sorting the rotations lexicographically is the only work the transform does. Reading down the seven rows, notice that the sort has grouped the string by what comes after each position.
-
The last character of a rotation is the character standing immediately before its first character in the original. That is why the sort produces runs: rows 1 and 2 both begin with 'a' and both end in 'n', because both of those a's are preceded by an n in banana. The key is the row number of the original, and without it the transform cannot be undone.
-
Nothing has been compressed yet, and nothing could have been — the output is a permutation of the input, the same seven characters in a different order. What changed is the run structure, and that is the only thing that changed.
-
RLE charges two bytes per run, so five runs cost ten bytes against a seven-byte input. Its break-even never moves: the number of runs has to be under half the length, which here means three or fewer.
Answer
The panel prints annb$aa with key = 4, an average run of 1.4 characters, 10 bytes of RLE and a score of 0.70×. The transform did exactly what it promises — it lifted the average run by 40% without touching a single character — and the pipeline still lost, because seven characters is not enough text for that gain to cover two bytes per run. Double the word and the arithmetic flips. "bananabanana$" is thirteen characters and its transform is annnnbba$aaaa: six runs instead of five, while the length nearly doubled, giving 12 bytes against 13 and a score of 1.08×. That is the whole case for BWT — the run count is governed by how many distinct contexts the text has, not by how long it is, so the longer the block the better it pays, which is why bzip2 transforms blocks of up to 900 kB rather than words.
-
Learning path
Compression by hand
References (3)
- Insight blocks 1 and 2 — the transform itself: M. Burrows and D. J. Wheeler, "A Block-sorting Lossless Data Compression Algorithm." Digital Systems Research Center, Research Report 124, 1994.
- Insight block 3 — the aligners it turned into: B. Langmead, C. Trapnell, M. Pop and S. L. Salzberg, "Ultrafast and memory-efficient alignment of short DNA sequences to the human genome." Genome Biology 10, R25, 2009.
- And the one the block names outright: H. Li and R. Durbin, "Fast and accurate short read alignment with Burrows–Wheeler transform." Bioinformatics 25(14), 1754–1760, 2009.