HuffmanCoding Proof
HuffmanCoding Proof
• (sketch)
• Take any tree representing an arbitrary optimal prefix
code.
• Modify to a new tree such that the characters and with
lowest frequencies appear as sibling leaves of
maximum depth in .
• Thus and will have the same length codeword only
differing in the last bit.
• Show that will also be an optimal prefix code.
x a
y y
a b x b
a a
y b
x b x y
• -
• Thus .
• Similarly we can shown .
• But we know that is the optimal tree and hence .
• Hence Thus is an optimal tree in which and will have the
same length codeword only differing in the last bit.
• Thus
• It means