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?

  1. A. 16
  2. B. 14
  3. C. 30
  4. 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

Exams that ask this topic