GATE Computer ScienceEasyGATE CS (PYQ pattern)

Twelve symbols, all with the same frequency 1, are encoded with an optimal Huffman code. What is the total number of bits to encode one occurrence of each symbol?

  1. A. 44
  2. B. 48
  3. C. 36
  4. D. 40

Correct answer: A. 44

With equal weights Huffman builds an almost complete tree: since 8 < 12 ≤ 16, 2·(12 − 8) = 8 symbols get 4-bit codes and the other 4 get 3-bit codes: 8·4 + 4·3 = 44. Giving all 12 symbols ⌈log₂ 12⌉ = 4 bits gives 48.

More Algorithms questions

Exams that ask this topic