GATE Computer ScienceHardGATE CS (PYQ pattern)

Instruction frequencies are 0.5, 0.25, 0.125, 0.0625 and 0.0625. What is the minimum average opcode length with a prefix code, and how many bits does a fixed-length 5-opcode encoding need?

  1. A. 1.8750 bits versus 3 bits
  2. B. 1.8750 bits versus 2 bits
  3. C. 1.5 bits versus 2 bits
  4. D. 2.0 bits versus 3 bits

Correct answer: A. 1.8750 bits versus 3 bits

The probabilities are powers of ½, so code lengths 1, 2, 3, 4, 4 give 0.5 + 0.5 + 0.375 + 0.25 + 0.25 = 1.875 bits; fixed length needs ⌈log₂5⌉ = 3 bits.

More Computer Organization and Architecture questions

Exams that ask this topic