Huffman codebook
Build a deterministic prefix codebook from character frequencies and compare data bits with UTF-8 length.
The example value has been entered. Check it immediately or change the value.
Input is processed in the browser. Refreshing returns a sample value.
Instructions and example
No. Frequency ties use code-point string order to build a deterministic tree. A single-symbol input receives code 0.
BANANA BANDANA contains A 6 times and N 4 times. Its codebook uses 28 data bits versus 112 bits for the UTF-8 source.
At most 256 distinct code points. Codebook storage overhead is excluded, so this is not a compressed file size or format.
Frequently asked questions
Do equal frequencies produce different codes on each run?
No. Frequency ties use code-point string order to build a deterministic tree. A single-symbol input receives code 0.
Is the displayed bit count a compressed file size?
At most 256 distinct code points. Codebook storage overhead is excluded, so this is not a compressed file size or format.
Calculation criteria and reference materials
- RFC 1951 — Huffman Coding
At most 256 distinct code points. Codebook storage overhead is excluded, so this is not a compressed file size or format.
Verification of calculation criteria: · Calculation·verification principles · Report errors