GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A TM (blank B, start q0 on the leftmost input cell, halting state qa) has rules δ(q0,0) = (q0,0,R); δ(q0,1) = (q0,1,R); δ(q0,B) = (q1,B,L); δ(q1,1) = (q1,0,L); δ(q1,0) = (qa,1,L); δ(q1,B) = (qa,1,L). It is run once on each of the 16 binary inputs of length 4. What is the TOTAL number of moves over all 16 runs?

  1. A. 111
  2. B. 96
  3. C. 80
  4. D. 112

Correct answer: A. 111

The machine is a binary incrementer: 4 moves right, 1 move onto the last bit, then one move per trailing 1 plus the final write. For an input with t trailing 1s it makes 5 + t + 1 moves (t = 4 gives 10 for 1111). Trailing-1 counts: t = 0 for 8 inputs, 1 for 4, 2 for 2, 3 for 1, 4 for 1, so Σ(t + 1) = 8 + 8 + 6 + 4 + 5 = 31. Total = 16·5 + 31 = 111.

More Theory of Computation questions

Exams that ask this topic