Draft

Burrows-Wheeler transform I. Coding

29 of 34denesnori

Description:

The Burrows-Wheeler transform (BWT) is useful for data compression.The algorithm tends to arrange runs of the same character together. The BWT algorithm is used in bioinformatics and in the bzip3 data compression program.

The algorithm:
1, append '|' at the end of the input text. (It is required to unequivocally reconstruct the string, otherwise you can only cyclicly reconstruct the input.),
2, get all possible cyclic permutations (cyclic rotations) of the text, store them in a transformation table,
3, sort the permutations (the rows) into lexicographic order,
4, take the last column as output. (The returned text should include the '|' character).

Hint: note that Javascript's sort() method puts '|' after any letter of the alphabet.

Example:

Input:
ananas

Append '|' at the end of the string:
ananas|

All cyclic rotations:
ananas|
|ananas
s|anana
as|anan
nas|ana
anas|an
nanas|a

Sorting all rows into lexicographic order then take the last column
ananas|
anas|an as|anan
nanas|a
nas|ana
s|anana
|ananas

Output: last column
|nnaaas

Please note, that it is a coincidence that the first character of the returned text is '|'. You can't take this for granted.

For further information read https://en.wikipedia.org/wiki/Burrows%E2%80%93Wheeler_transform

Algorithms

Stats:

CreatedJul 6, 2016
Warriors Trained206
Total Skips73
Total Code Submissions59
Total Times Completed34
JavaScript Completions29
C# Completions7
Total Stars0
% of votes with a positive feedback rating79% of 19
Total "Very Satisfied" Votes14
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes3
Total Rank Assessments16
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • denesnori Avatar
  • user5036852 Avatar
Ad