Variable-length prefix-free coding algorithm that predates Huffman coding. Divides symbols recursively by frequency to create binary codes, though not always optimal.
| Property | Value |
|---|---|
| Category | Compression Algorithms |
| Sub-category | Statistical |
| Security status | π Educational Only |
| Complexity | Intermediate |
| Inventor | Claude Shannon, Robert Fano |
| Year | 1948 |
| Origin | πΊπΈ United States |
| Source | algorithms/compression/shannon-fano.js |
Status: π Educational Only
No vulnerabilities are recorded for this implementation.
3 vectors ship with this algorithm and run in the test suite. Byte values are hexadecimal.
Vector 1 β Basic frequency encoding
| Field | Value |
|---|---|
input |
414141424243 |
expected |
06000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 β¦ (518 bytes; the full value is in the source) |
Vector 2 β Alphabet frequency test
| Field | Value |
|---|---|
input |
414243444546 |
expected |
06000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 β¦ (518 bytes; the full value is in the source) |
Vector 3 β Repeated pattern encoding
| Field | Value |
|---|---|
input |
414241424142 |
expected |
06000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 β¦ (517 bytes; the full value is in the source) |