GATE Computer ScienceHardGATE CS (PYQ pattern)
A DPDA has start state q0, bottom symbol Z, accepting state set {q0} (acceptance by final state after the whole input is read) and transitions (stack top written first): δ(q0, a, Z) = (q1, AZ); δ(q0, b, Z) = (q1, BZ); δ(q1, a, A) = (q1, AA); δ(q1, b, B) = (q1, BB); δ(q1, a, B) = (q1, ε); δ(q1, b, A) = (q1, ε); δ(q1, ε, Z) = (q0, Z). (In q1 with Z on top only the ε-move exists, so the machine is deterministic.) How many strings over {a, b} of length at most 8 does it accept?
- A. 70
- B. 99
- C. 98
- D. 35
Correct answer: B. 99
The stack is a signed counter: A's record surplus a's, B's surplus b's, and whenever the counter returns to zero the ε-move takes the machine back to the accepting state q0. So it accepts exactly the strings with n_a = n_b, including ε (q0 is the start state). Count: C(0,0) + C(2,1) + C(4,2) + C(6,3) + C(8,4) = 1 + 2 + 6 + 20 + 70 = 99.
More Theory of Computation questions
- A nondeterministic PDA over {a, b, c} (acceptance by final state at the end of the input) guesses at the start whether to check #a = #b…
- A single-tape TM with blank B starts in q0 on the leftmost cell of the input 10111. Its rules (state, symbol) → (state, write, move) are…
- 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) =…
- 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) =…