Bölüm 5 · Simülatör

String Transformation: Burrows-Wheeler Transform

← Bölüm 5
1. Generate Rotations
2. Sort Rotations
3. Read Last Column

Rotation Table

BWT Result

–

Not created yet.

Step

Ready.

Burrows-Wheeler Transform

Generate all cyclic rotations, sort them lexicographically, and read the final column to produce the BWT.

How to use

  • Type a string of up to 12 characters and press Load Input (or Reset to start over with the same input).
  • append $ adds the end marker $, which sorts before every letter and digit. Without it the transform is still computed, but the original string can only be recovered if the row index is stored as well.
  • Step Forward performs one step: first one rotation per step, then the sort, then reading the last column. Auto Run plays the remaining steps (press again to pause).
  • In the table the first column (F) is shown in the link color and the last column (L) in red; the newest rotation is highlighted. After sorting, the outlined row is the original string, and Shift is the rotation offset (with $ this column is the suffix array).

Why it is useful

Sorting rotations groups characters that precede similar contexts, so the last column tends to contain long runs of equal characters (for example BANANA$ → ANNB$AA). Run-length encoding and move-to-front coding then compress it well; this is the core of bzip2.

Inverting the transform

The first column F is the sorted last column L. The LF-mapping links the i-th occurrence of a character in L to its i-th occurrence in F, which lets the original string be rebuilt backwards from the row that holds it.

Complexity

This naive method builds n rotations of length n and sorts them: O(n² log n) time and O(n²) space. Practical implementations derive the BWT from a suffix array in O(n) or O(n log n) time.