Suppose the letters have probabilities , respectively.
Which of the following is the Huffman code for the letter ?
View worked solution
Answer: A
To find the Huffman code, we 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 node with probability .
Assigning 0 to the left branch and 1 to the right branch at each step of the tree yields the following prefix codes:
- :
- :
- :
- :
- :
- :
This matches the code sequence given in Option A.
Free practice · Your answers on this page are not saved.
