Huffman coding (Variable length coding)
Some characters are more frequent than others and for them we can uses only one or two bits. Assign shorter codes to characters that occur more frequently.
Steps
- Calculate a frequency for each node
- Connect smallest numbers
- Assign 0 to left branches, 1 to right branches
- Each encoding is a path from the root