GATE Computer ScienceModerateGATE CS (PYQ pattern)

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) = (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) = (q1,X,R); δ(q1,1) = (q3,X,L); δ(q2,1) = (q2,1,R); δ(q2,X) = (q2,X,R); δ(q2,0) = (q3,X,L); δ(q3,0) = (q3,0,L); δ(q3,1) = (q3,1,L); δ(q3,X) = (q3,X,L); δ(q3,B) = (q0,B,R). Which language does it accept?

  1. A. { 0ⁿ1ⁿ : n ≥ 0 } (all 0s before all 1s)
  2. B. { w : the number of 0s equals the number of 1s }
  3. C. { w : w has strictly more 0s than 1s }
  4. D. { w wᴿ : w ∈ {0, 1}* } (even palindromes)

Correct answer: B. { w : the number of 0s equals the number of 1s }

Each round crosses off the first uncrossed symbol and then one opposite symbol to its right; if it finds none, the machine halts without accepting. Only when everything is crossed off does it reach the blank in q0 and accept, so it decides n₀ = n₁ (in any order).

More Theory of Computation questions

Exams that ask this topic