GATE Computer ScienceHardGATE CS (PYQ pattern)

A PDA with start state q0, bottom symbol Z, input alphabet {a, b} and accepting state qf (acceptance by final state) has transitions: δ(q0, a, Z) = {(q0, AZ), (q0, AAZ)}; δ(q0, a, A) = {(q0, AA), (q0, AAA)}; δ(q0, b, A) = {(q1, ε)}; δ(q1, b, A) = {(q1, ε)}; δ(q1, ε, Z) = {(qf, Z)}. Stack tops are written first. How many strings of length exactly 12 does it accept?

  1. A. 4
  2. B. 3
  3. C. 2
  4. D. 6

Correct answer: B. 3

On each a the PDA nondeterministically pushes 1 or 2 A's, then each b pops one A and the final ε-move needs Z on top. So it accepts aⁿbᵐ with n ≥ 1 and n ≤ m ≤ 2n; with n + m = 12 that gives n = 4, 5, 6: 3 strings.

More Theory of Computation questions

Exams that ask this topic