An optimal prefix code minimizes probability-weighted codeword length among all prefix codes for the source.
For a source symbol and a code , the expected codeword length is
If symbols of probabilities have codeword lengths and in an optimal prefix code, then . Otherwise, exchanging their codewords preserves the prefix property and changes the expected length by
contradicting optimality.
Every optimal binary prefix code has two codewords of maximal length that differ only in their final bit. Indeed, choose a deepest leaf in the prefix tree. If its sibling were not a codeword, maximality of the depth would make that sibling subtree empty, so the chosen word could be shortened by deleting its final bit. This would preserve prefix-freeness and reduce expected length.
Distinct tree shapes can have the same minimum expected length, particularly when Huffman merges have ties.

Articles by others on the same topic (0)

There are currently no matching articles.