Huffman Coding and the Sibling Exchange

Prove why the two least-weighted symbols can be combined first and calculate a weighted average length.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Put rare symbols at deep leaves
  2. Merging adds exactly the combined weight

Put rare symbols at deep leaves

An optimal full binary prefix tree can arrange the two least-weighted symbols at a pair of sibling leaves of greatest depth. Start with deepest siblings and exchange their labels with the lightest symbols as needed. Moving a lighter weight deeper and a heavier one shallower does not increase the weighted length. The siblings can then be treated as one combined symbol in a reduced problem.

Merging adds exactly the combined weight

Expanding the combined leaf adds one bit to both children, increasing cost by their total weight. Repeatedly merge the smallest available pair. Weights \(0.4,0.3,0.2,0.1\) permit lengths \(1,2,3,3\), giving average \(1.9\) bits. Ties can produce other equally good assignments. Prefix trees give the feasibility condition. Entropy provides a lower bound on ideal expected length.[1][2]

References

  1. David A. Huffman, A Method for the Construction of Minimum-Redundancy Codes ↩
  2. David J. C. MacKay, Information Theory, Inference, and Learning Algorithms ↩