GATE Computer ScienceHardGATE CS

A single-tape Turing machine has blank B and starts in q0 on the leftmost cell of a binary numeral (MSB at the left). 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,R); δ(q1,B) = (qa,1,R). qa is the halting state. How many moves does the machine make on the input 10011111 before halting?

  1. A. 15
  2. B. 16
  3. C. 13
  4. D. 14

Correct answer: A. 15

The head moves right over 8 symbols (8 moves), turns at the blank (1 move), flips the five trailing 1s to 0 (5 moves) and finally writes 1 over the 0 (1 move): 8 + 1 + 5 + 1 = 15. The machine is a binary incrementer; the result is 10100000.

More Theory of Computation questions

Exams that ask this topic