GATE Computer ScienceHardGATE CS (PYQ pattern)
A PDA with start state q0 and bottom symbol Z accepts by EMPTY STACK. Its transitions (stack top written first) are: δ(q0, a, Z) = {(q0, AZ)}; δ(q0, a, A) = {(q0, AA)}; δ(q0, b, A) = {(q1, ε)}; δ(q1, b, A) = {(q1, ε)}; δ(q1, a, Z) = {(q0, AZ)}; δ(q1, ε, Z) = {(q1, ε)}. How many strings of length at most 8 does it accept?
- A. 16
- B. 14
- C. 30
- D. 15
Correct answer: D. 15
Z can be popped only in q1, which is reached only after at least one b. The machine reads blocks aⁿbⁿ (n ≥ 1) and may start a new block from q1 when Z is exposed. So L = { aⁿbⁿ : n ≥ 1 }⁺, and ε is NOT accepted (q0 has no ε-move). Strings of length 2m correspond to compositions of m: 1 + 2 + 4 + 8 = 15 for m = 1…4.
More Theory of Computation questions
- A nondeterministic PDA (start q0, bottom symbol Z, final state qf, acceptance by final state) has the rules: in q0 it pushes A or B for…
- A DPDA has start state q0, bottom symbol Z, accepting state set {q0} (acceptance by final state after the whole input is read) and…
- 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)…