fixed length encoding, variable length encoding:

An encoding is a prefix free code if no code of a character is a prefix of another character code.

It can be proved that the optimal data compression achievable by a character code can always be achieved with a prefix code.

Huffman encoding.

Each prefix code can be represented as a tree. The tree of an optimal encoding must be a full binary tree.

is alphabet, is the frequency of , and is the depth of in .

Lemma 125.1.

Let and be two characters with the lowest frequencies in . Then there exists an optimal prefix code for in which the codewords for and have the same length and differ only in the last bit.