The binary Huffman coding algorithm repeatedly merges the two currently least probable symbols into one meta-symbol whose probability is their sum. After recursively constructing a code for the smaller alphabet, append and to the meta-symbol's codeword to obtain codewords for the merged pair. The result is a binary prefix code.
To prove optimality, begin with an optimal prefix-code tree. It may be taken to be full, since an internal vertex with one child can be suppressed and all codewords below it shortened. Two leaves of maximum depth are siblings. By exchanging labels, without changing lengths, assign two least probable symbols to such a sibling pair: moving a smaller probability to a no-shorter codeword cannot increase the expected length. Contracting this pair to one leaf replaces their contribution by plus the constant . If the contracted code were not optimal for the reduced alphabet, replacing it by a better one and then expanding the merged leaf would improve the original code. Mathematical induction on the number of symbols now proves that the Huffman construction minimizes expected word length.
False. For probabilities , first merge the two symbols. Subsequent ties allow Huffman trees with length multisets and , both of expected length .
False. For probabilities , every length-two code is optimal. A code in which the and symbols are sibling leaves is optimal, but no Huffman construction produces that labelled tree, because its first merge must pair with a symbol.
True. The Huffman tree is a full binary tree, so its leaves form a complete prefix code. The Kraft inequality is therefore an equality:

Articles by others on the same topic (0)

There are currently no matching articles.