Data transformation algorithm that restructures data for better compressibility by moving recently seen symbols to the front of the alphabet. Core component of BZIP2.
| Property | Value |
|---|---|
| Category | Compression Algorithms |
| Sub-category | Transform |
| Security status | π Educational Only |
| Complexity | Intermediate |
| Inventor | Bentley, Sleator, Tarjan, Wei |
| Year | 1986 |
| Origin | πΊπΈ United States |
| Source | algorithms/compression/mtf.js |
Status: π Educational Only
No vulnerabilities are recorded for this implementation.
7 vectors ship with this algorithm and run in the test suite. Byte values are hexadecimal.
Vector 1 β Empty input
| Field | Value |
|---|---|
input |
(empty) |
expected |
(empty) |
Vector 2 β Single character - position 65 in initial alphabet
| Field | Value |
|---|---|
input |
41 |
expected |
41 |
Vector 3 β Repeated character - second occurrence becomes 0
| Field | Value |
|---|---|
input |
4141 |
expected |
4100 |
Vector 4 β Two different characters - both at original positions
| Field | Value |
|---|---|
input |
4142 |
expected |
4142 |
Vector 5 β Pattern ABA - A moves to front after first occurrence
| Field | Value |
|---|---|
input |
414241 |
expected |
414201 |
Vector 6 β ABACA pattern - shows MTF ordering dynamics
| Field | Value |
|---|---|
input |
4142414341 |
expected |
4142014301 |
Vector 7 β Classic banana example - demonstrates compression potential
| Field | Value |
|---|---|
input |
62616e616e61 |
expected |
62626e010101 |