How to resolve the algorithm Burrows–Wheeler transform step by step in the BQN programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Burrows–Wheeler transform step by step in the BQN programming language
Table of Contents
Problem Statement
The Burrows–Wheeler transform (BWT, also called block-sorting compression) rearranges a character string into runs of similar characters. This is useful for compression, since it tends to be easy to compress a string that has runs of repeated characters by techniques such as move-to-front transform and run-length encoding. More importantly, the transformation is reversible, without needing to store any additional data. The BWT is thus a "free" method of improving the efficiency of text compression algorithms, costing only some extra computation.
Source: Burrows–Wheeler transform
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Burrows–Wheeler transform step by step in the BQN programming language
Source code in the bqn programming language
stx←@+2
BWT ← { # Burrows-Wheeler Transform and its inverse as an invertible function
𝕊: "Input contained STX"!⊑stx¬∘∊𝕩 ⋄ (⍋↓𝕩) ⊏ stx∾𝕩;
𝕊⁼: 1↓(⊑˜⍟(↕≠𝕩)⟜⊑ ⍋)⊸⊏ 𝕩
}
BWT "banana"
"annb␂aa"
BWT⁼ BWT "banana"
"banana"
BWT "appellee"
"e␂elplepa"
BWT⁼ BWT "appellee"
"appellee"
BWT "dogwood"
"do␂oodwg"
BWT⁼ BWT "dogwood"
"dogwood"
BWT "TO BE OR NOT TO BE OR WANT TO BE OR NOT?"
"?OOORREEETTRTW BBB ATTT NNOOONOO␂ "
BWT⁼ BWT "TO BE OR NOT TO BE OR WANT TO BE OR NOT?"
"TO BE OR NOT TO BE OR WANT TO BE OR NOT?"
BWT "SIX.MIXED.PIXIES.SIFT.SIXTY.PIXIE.DUST.BOXES"
"STEXYDST.E.IXXIIXXSSMPPS.B..EE.␂.USFXDIIOIIIT"
BWT⁼ BWT "SIX.MIXED.PIXIES.SIFT.SIXTY.PIXIE.DUST.BOXES"
"SIX.MIXED.PIXIES.SIFT.SIXTY.PIXIE.DUST.BOXES"
BWT "␂abc"
Error: Input contained STX
You may also check:How to resolve the algorithm Plot coordinate pairs step by step in the Factor programming language
You may also check:How to resolve the algorithm Sum of squares step by step in the Swift programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the Plan programming language
You may also check:How to resolve the algorithm Real constants and functions step by step in the Elixir programming language
You may also check:How to resolve the algorithm Zhang-Suen thinning algorithm step by step in the Ruby programming language