Algorithms
Dynamic Programming & Greedy Algorithms
GATE 2007
Medium
What is the average length of the correct Huffman code for the letters a,b,c,d,e,f with probabilities 1/2, 1/4, 1/8, 1/16, 1/32, 1/32?
- A3
- B2.1875
- C2.25
- 1.9375
Explanation
Average length = Σ(probability × code length) = (1/2)(1) + (1/4)(2) + (1/8)(3) + (1/16)(4) + (1/32)(5) + (1/32)(5) = 0.5+0.5+0.375+0.25+0.15625+0.15625 = 1.9375.
Source: GATE CS 2007 (2007)
This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.