All mock tests are FREE till 31 December — register to save your progress
Unit 8 · Theory of Computation and Compilers Paper 2 CS · September 2022

Consider the NPDA M = ({q0, q1, qf}, {a, b}, {1, z}, δ, q0, z, {qf}) with
δ(q0, λ, z) = {(qf, z)}
δ(q0, a, z) = {(q1, 11z)}
δ(q1, a, 1) = {(q1, 111)}
δ(q1, b, 1) = {(q1, λ)}
δ(q1, λ, z) = {(qf, z)}
Which language L is accepted by the NPDA?

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: B. L = {anb2n : n ≥ 0}

Explanation

Each a pushes two 1's (11z on the first a, 1 → 111 afterwards) and each b pops one, so z is exposed again only after 2n b's. The λ-move from q0 also accepts the empty string: {anb2n : n ≥ 0}.

More Theory of Computation and Compilers questions