Data Structures & AlgorithmsHardGATE CS

Symbols occur with frequencies 24, 26, 33, 34, 35, 38. How many bits does an optimal (Huffman) prefix code need for the whole message, and how many would a fixed-length code need?

  1. A. 521 and 570
  2. B. 497 and 570
  3. C. 497 and 1140
  4. D. 473 and 570

Correct answer: B. 497 and 570

Total Huffman bits = sum of all merge costs (repeatedly merge the two smallest) = 497. A fixed-length code needs ⌈log₂6⌉ = 3 bits per symbol: 570.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic