Two symbols only — Huffman coding
corethe floor Huffman cannot break
Answer
average 1.0000 bits/symbol, 100 bits total
Why this example is worth doing
With only two symbols every code is one bit, no matter how lopsided the probabilities. Huffman assigns whole bits, so it can never spend less than one bit per symbol, which is where its optimality claim runs out. The page states the bound precisely — Huffman is within one bit per symbol of the entropy — and points at arithmetic coding as the method that goes below it. This is the cleanest possible illustration of the gap.
Try your own input in the Huffman coding. Build the tree from text or from frequencies, with the merge order and canonical codes.
How the answer is reached
Codebook
| symbol | code |
|---|---|
| b | 0 |
| a | 1 |
Merge order
| step | left | right | weight |
|---|---|---|---|
| 1 | 10 | 90 | 100 |