GATE Computer ScienceHardGATE CS (PYQ pattern)

A text uses 8 symbols with frequencies 5, 9, 12, 13, 16, 45, 3 and 7. If a Huffman code is built, the total number of bits needed for the whole text (sum of frequency × code length) is:

  1. A. 330
  2. B. 284
  3. C. 272
  4. D. 301

Correct answer: B. 284

Huffman merging costs: 3+5 = 8, 7+8 = 15, 9+12 = 21, 13+15 = 28, 16+21 = 37, 28+37 = 65, 45+65 = 110; the sum of all merged weights is 8+15+21+28+37+65+110 = 284. A fixed 3-bit code would need 330.

More Algorithms questions

Exams that ask this topic