Burrows-Wheeler Transform
Burrows-Wheeler Transform
Implement the forward and inverse BWT.
Functions
func BWTForward(data []byte) ([]byte, int)
func BWTInverse(last []byte, primary int) []byte
Behavior
BWTForwardreturns the last column and the primary index (row of the original string in the sorted rotations).BWTInversereconstructs the original data fromlastandprimary.- If
datais empty, return[]byte{}andprimary=0. primaryis zero-based.
Constraints
len(data) <= 512(naive O(n^2 log n) rotation sort is acceptable).
Notes
- Rotations are compared lexicographically as byte sequences.
- The transform is reversible only with the primary index.
Run tests to see results
No issues detected