Quaternary Huffman coding

ID: quaternary-huffman-coding

Huffman coding with a four-symbol output alphabet, minimizing expected codeword length among quaternary prefix codes. Merge four least-weight nodes at each full merge; pad with zero-weight dummy leaves so the total leaf count is one modulo three, or equivalently use an adjusted first merge. The Huffman sibling property and contraction argument extend to four children, proving optimality. Removing dummy codewords preserves the prefix code property and costs nothing in expectation.

New to topics? Read the docs here!