Suppose the letters have probabilities , respectively.
What is the average length of the Huffman code for the letters ?
View worked solution
Answer: D
To find the average length of the Huffman code, we first construct the Huffman tree by repeatedly merging the two nodes with the smallest probabilities:
- Initial probabilities: , , , , ,
- Merge and (each ) to form parent node with probability .
- Merge () and () to form parent node with probability .
- Merge () and () to form parent node with probability .
- Merge () and () to form parent node with probability .
- Merge () and () to form the root with probability .
From this tree, the code lengths () for each letter are:
- : bit
- : bits
- : bits
- : bits
- : bits
- : bits
The average code length () is calculated as:
Thus, the average length of the Huffman code is .
Free practice · Your answers on this page are not saved.
