GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A branch alternates T, N, T, N, … for 20 executions, starting with T. A 2-bit saturating counter (states 0-3, predicts taken in states 2 and 3; taken increments, not-taken decrements) is run twice on this stream: once starting in state 1 and once starting in state 0. How many mispredictions does it make in each run (state-1 run, state-0 run)?

  1. A. 20 and 20
  2. B. 10 and 10
  3. C. 10 and 20
  4. D. 20 and 10

Correct answer: D. 20 and 10

From state 1 the counter flips 1↔2 and each prediction is the opposite of the outcome (always wrong, 20). From state 0 it flips 0↔1, predicts not-taken always, and so misses only the 10 T outcomes.

More Computer Organization and Architecture questions

Exams that ask this topic