The pushdown automation M = ({q0 , q1 , q2 }, {a, b}, {0, 1}, δ, q0 , 0, {q0…

2014

The pushdown automation M = ({q0 , q1 , q2 }, {a, b}, {0, 1}, δ, q0 , 0, {q0 }) with

δ(q0 , a, 0) = {(q1 , 10)}

δ(q1 , a, 1) = {(q1 , 11)}

δ(q1 , b, 1) = {(q2 , λ)}

δ(q2 , b, 1) = {(q2 , λ)}

δ(q2 , λ, 0) = {(q0 , λ)}

Accepts the language

  1. A.

    L = {an bm | n, m ≥ 0}

  2. B.

    L = {an bn | n ≥ 0}

  3. C.

    L = {an bm | n, m > 0}

  4. D.

    L = {an bn | n > 0}

Attempted by 65 students.

Show answer & explanation

Correct answer: B

Answer: The language is all strings of the form a^n b^n with n ≥ 0.

  • How a's are handled: On the first a the transition from the start state pushes a '1' above the initial '0' and moves to the counting state; further a's push additional '1's. After n a's the stack contains n copies of '1' above the bottom '0'.

  • How b's are handled: The first b causes a transition that pops one '1' and moves to the b-consuming state. Each subsequent b pops one more '1'. Thus each b removes exactly one symbol corresponding to an earlier a.

  • Returning to accept: When all '1's have been popped the stack top becomes the initial '0'. There is an epsilon transition that pops the '0' and returns to the start state, which is accepting. Therefore the input is accepted exactly when the number of b's equals the number of a's and all a's precede the b's.

  • Empty string: Since the machine starts in an accepting state and can take no transitions on empty input, the empty string is accepted (this corresponds to n = 0).

  • Conclusion: The accepted language is {a^n b^n | n ≥ 0}.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor