GATE Computer ScienceVery hardGATE CSE
A TM (blank B) has rules: δ(q0,a) = (q1,X,R); δ(q0,Y) = (q3,Y,R); δ(q0,B) = (qa,B,S); δ(q1,a) = (q1,a,R); δ(q1,Y) = (q1,Y,R); δ(q1,b) = (q2,Y,L); δ(q2,a) = (q2,a,L); δ(q2,Y) = (q2,Y,L); δ(q2,X) = (q0,X,R); δ(q3,Y) = (q3,Y,R); δ(q3,B) = (qa,B,S). It starts in q0 on the leftmost symbol and every rule applied counts as one step; qa halts and accepts. For input aaabbb, how many steps are executed up to acceptance?
- A. 23
- B. 25
- C. 26
- D. 29
Correct answer: B. 25
Each of the three passes (mark an a, walk right, mark a b, walk back to X, step right) costs 7 steps = 21; then q0 reads Y, q3 skips the two Y's and accepts on the blank: 4 more. Total 25.
More Theory of Computation questions
- Which regular expression (over {a, b}, + means union) generates exactly the strings with an even number of b's?
- The pumping lemma for regular languages states that some length p exists such that every w ∈ L with |w| ≥ p can be split w = xyz with |xy|…
- For a context-free grammar G given as input, how many of the following problems are undecidable? (a) Is L(G) = Σ? (b) Is L(G) regular? (c)…
- A DFA reads a binary string most-significant bit first (leading zeros allowed) and tracks the value so far modulo 12, accepting exactly…
- Let L be the set of strings over {a, b} in which the third symbol from the right is a, or the last symbol is b (strings shorter than 3…
- An NFA over {a, b} has states 0–4, start state 0 and accepting state 4. Transitions: 0 –a→ {0,1}; 0 –b→ {0}; 1 –a,b→ {2}; 2 –a,b→ {3}; 3…