An optimal prefix code minimizes probability-weighted codeword length among all prefix codes for the source.
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 bycontradicting 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.
Articles by others on the same topic
There are currently no matching articles.