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?
- A. 111
- B. 96
- C. 80
- 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
- A TM with rules δ(q0,a) = (q1,X,R); δ(q0,Y) = (q4,Y,R); δ(q1,a) = (q1,a,R); δ(q1,Y) = (q1,Y,R); δ(q1,b) = (q2,Y,R); δ(q2,b) = (q2,b,R)…
- A TM over {0, 1} (blank B, start q0 on the leftmost cell, accepts at qa, rejects by having no applicable rule) has rules: δ(q0,X) =…
- For the same TM with rules δ(q0,X) = (q0,X,R); δ(q0,0) = (q1,X,R); δ(q0,1) = (q2,X,R); δ(q0,B) = (qa,B,R); δ(q1,0) = (q1,0,R); δ(q1,X) =…
- L₁ is context-free, L₂ is regular and L₃ is deterministic context-free (all over the same alphabet Σ, complements taken w.r.t. Σ). Which…
- Which of the following statements about deterministic context-free languages (DCFLs) are correct? I. The complement of a DCFL is a DCFL…
- Which of the following statements about context-free languages are correct? I. The intersection of a CFL with a DCFL is always a CFL. II…