Huffman coding
Gives each letter of a text a code of 0s and 1s, short for letters used often and long for rare ones, with no code the start of another, so the bits read back without gaps. The two lightest trees are joined again and again until one tree holds every letter.
the queue, lightest at the front
the tree: 0 down to the left, 1 down to the right
- comparisons to line the letters up
- 0
- joins
- 0
step 1 of 1
Examples