Cost of a Huffman Tree
Let p1, p2, ... , pm be the probabilities for the symbols a1, a2, ... ,am, respectively.
Define the cost of the Huffman tree T to bewhere ri is the length of the path from the root to ai.
C(T) is the expected length of the code of a symbol coded by the tree T.