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?
- A. { 0ⁿ1ⁿ : n ≥ 0 } (all 0s before all 1s)
- B. { w : the number of 0s equals the number of 1s }
- C. { w : w has strictly more 0s than 1s }
- 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
- 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…
- Which of the following languages over {a, b, c} is NOT context-free?
- Which one of the following languages is regular?