Anonymous user
Move-to-front algorithm: Difference between revisions
m
indented the two tables.
(Added Wren) |
m (indented the two tables.) |
||
Line 2:
Given a symbol table of a ''zero-indexed'' array of all possible input symbols
[[wp:Move-to-front transform|this algorithm]] reversibly transforms a sequence
of input symbols into an array of output numbers (indices).
The transform in many cases acts to give frequently repeated input symbols
lower indices which is [[wp:Move-to-front_transform#Use_in_practical_data_compression_algorithms| useful in some compression algorithms]].
;Encoding algorithm:
Line 12 ⟶ 14:
move that symbol to the front of the symbol table
</pre>
;Decoding algorithm:
Line 20 ⟶ 23:
move that symbol to the front of the symbol table
</pre>
;Example:
Line 25 ⟶ 29:
the characters 'a'-to-'z'
:::::{| class="wikitable" border="1"
|-
! Input
Line 55 ⟶ 59:
| 'orbacdefghijklmnpqstuvwxyz'
|}
Decoding the indices back to the original symbol order:
:::::{| class="wikitable" border="1"
|-
! Input
Line 87 ⟶ 92:
| 'orbacdefghijklmnpqstuvwxyz'
|}
;Task:
|