N-ary run length encoding
Juan Francisco Rodr
í
guez Herrera
Vicente Gonz
á
lez Ruiz
September 12, 2016
Contents
1
Intro
2
Compressor
3
Decompressor
1
Intro
RLE for N-ary alphabets (alphabets of size N), where typically, N=256.
2
Compressor
While there are symbols to encode:
Let
s
the next symbol.
Read the next
n
consecutive symbols equal to
s
.
Write the pair
n
s
.
3
Decompressor
While there are
n
s
pairs to decode:
Write
n
-times the symbol
s
.
Example
The runs:
aaaabbbbbaaaaaabbbbbbbcccccc
are encoded as:
4
a
5
b
6
a
7
b
6
c