GATE / CS ARCHIVE

GATE CSE 2007 / QUESTION 77

Average Huffman code length

Algorithms · Greedy Algorithms · Full GATE CSE 2007 paper

GATE 2007, Q77 2 marks · MCQ
Report issue

Greedy Algorithms

Question 77, GATE 2007: Letters a,b,c,d,e,f occur with probabilities 1/2,1/4,1/8,1/16,1/32,1/32, respectively. What is the average length of an optimal binary Huffman code (the linked Q76 code)? Derive the code lengths from these probabilities.
Options:
(A) 3
(B) 2.1875
(C) 2.25
(D) 1.9375
Question 77, GATE 2007: Letters a,b,c,d,e,f occur with probabilities 1/2,1/4,1/8,1/16,1/32,1/32, respectively. What is the average length of an optimal binary Huffman code (the linked Q76 code)? Derive the code lengths from these probabilities.
Options:
(A) 3
(B) 2.1875
(C) 2.25
(D) 1.9375
Question 77, GATE 2007: Letters a,b,c,d,e,f occur with probabilities 1/2,1/4,1/8,1/16,1/32,1/32, respectively. What is the average length of an optimal binary Huffman code (the linked Q76 code)? Derive the code lengths from these probabilities.
Options:
(A) 3
(B) 2.1875
(C) 2.25
(D) 1.9375
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Approach. Average code length is probability-weighted, not the arithmetic mean of the six word lengths. Huffman merging gives lengths 1,2,3,4,5,5, with the shortest code assigned to the most frequent symbol.

2. Derivation and interpretation. Using the independently derived lengths 1,2,3,4,5,5, the weighted average is (1/2)*1+(1/4)*2+(1/8)*3+(1/16)*4+(1/32)*5+(1/32)*5 = 31/16 = 1.9375 bits per symbol. Answer D.

Original paper, page 19