Prefix Codes and the Kraft Inequality

Use the leaves of a binary tree to constrain possible code lengths and demonstrate an instantaneously decodable example.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. No codeword may be an ancestor of another
  2. A length consumes a fraction of the available tree

No codeword may be an ancestor of another

In a binary prefix code, interpret each symbol’s bits as a path from the root. Encountering a leaf finishes one symbol without looking ahead. For codewords \(0,10,11\), each word identifies a leaf and no first word is an initial segment of another. The string \(01011\) consequently splits as \(0\), then \(10\), then \(11\).

A length consumes a fraction of the available tree

A leaf of length \(\ell\) claims fraction \(2^{-\ell}\) of all sufficiently long bit strings as descendants. The fractions of different prefix leaves are disjoint, so their sum is at most one. Lengths \(1,2,2\) fill the whole capacity. Lengths \(1,1,2\) exceed it. Huffman coding chooses lengths that minimize expected length for weighted symbols. Arithmetic coding represents complete sequences instead of assigning one fixed word per symbol.[1][2]

References

  1. David J. C. MacKay, Information Theory, Inference, and Learning Algorithms ↩
  2. Claude E. Shannon, A Mathematical Theory of Communication ↩