GATE Computer ScienceHardGATE CS (PYQ pattern)

Five instructions occur with relative frequencies 0.4, 0.2, 0.2, 0.1 and 0.1. A fixed-length opcode would need 3 bits. What is the minimum possible average opcode length (bits) with a variable-length prefix code, to one decimal?

  1. A. 3.0
  2. B. 2.5
  3. C. 2.2
  4. D. 2.0

Correct answer: C. 2.2

Huffman merging: 0.1+0.1 = 0.2; 0.2+0.2 = 0.4; 0.2+0.4 = 0.6; 0.4+0.6 = 1.0. Total of merged weights = 0.2 + 0.4 + 0.6 + 1.0 = 2.2 bits on average.

More Computer Organization and Architecture questions

Exams that ask this topic