GateAI
Context-Free Grammars and PDAs

GATE CSE 2023 · Q40

MCQ2 marksMedium

Time

Consider the pushdown automaton (PDA) PP below, which runs on the input alphabet {a,b}\{a, b\}, has stack alphabet {⊥,A}\{\bot, A\}, and has three states {s,p,q}\{s, p, q\}, with ss being the start state. A transition from state uu to state vv, labelled c/X/γc/X/\gamma, where cc is an input symbol or ϵ\epsilon, XX is a stack symbol, and γ\gamma is a string of stack symbols, represents the fact that in state uu, the PDA can read cc from the input, with XX on the top of its stack, pop XX from the stack, push in the string γ\gamma on the stack, and go to state vv. In the initial configuration, the stack has only the symbol ⊥\bot in it. The PDA accepts by empty stack. Which one of the following options correctly describes the language accepted by PP?

GATE CSE 2023 Q40 diagram

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: A) {am bn 1 ≤ m and n < m}

Context-Free Grammars and PDAs

Let us trace the operation of the PDA PP:

  1. Initial State (ss) and Reading 'aa':

    • Initially, the stack contains only the bottom marker ⊥\bot.

    • The only outgoing transition from ss that reads ⊥\bot is a/⊥/A⊥a/\bot/A\bot. Thus, the PDA must read at least one 'aa' to begin, which means m≥1m \ge 1.

    • For every subsequent 'aa' read at state ss, the self-loop a/A/AAa/A/AA pushes another AA. Therefore, after reading ama^m (m≥1m \ge 1), the stack contains Am⊥A^m\bot.

  2. Reading 'bb' and Transitioning to pp:

    • To read 'bb', the PDA must move to state pp using the transition b/A/ϵb/A/\epsilon, which pops one AA.

    • In state pp, any further 'bb' is read via the self-loop b/A/ϵb/A/\epsilon, popping one AA each time.

    • If nn number of 'bb's are read in total, nn symbols of AA are popped from the stack.

  3. Transitioning to Emptying State qq:

    • From state ss (if no 'bb' is read, i.e., n=0n=0), the transition to qq is ϵ/A/ϵ\epsilon/A/\epsilon, which requires popping an AA.

    • From state pp (if n≥1n \ge 1 'bb's are read), the transition to qq is also ϵ/A/ϵ\epsilon/A/\epsilon, which also requires popping an AA.

    • In both cases, entering qq strictly consumes at least one AA via an ϵ\epsilon-transition.

    • In state qq, the remaining AA's (if any) and the bottom marker ⊥\bot are popped via ϵ\epsilon-transitions (ϵ/A/ϵ\epsilon/A/\epsilon and ϵ/⊥/ϵ\epsilon/\bot/\epsilon) to make the stack empty.

  4. Constraint between mm and nn:

    • Out of the mm occurrences of AA pushed onto the stack, exactly nn are popped while reading bnb^n, and at least 1 must be popped to enter state qq.

    • Thus, n+1≤m  ⟹  n<mn + 1 \le m \implies n < m.

    • Since n≥0n \ge 0, we have 0≤n<m0 \le n < m and m≥1m \ge 1.

Therefore, the language accepted by PP is {ambn∣1≤m and n<m}\{a^m b^n \mid 1 \le m \text{ and } n < m\}, which corresponds to Option (A).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Context-Free Grammars and PDAs previous year question is Q40 of the GATE CSE 2023 paper. Find more GATE CSE PYQs on Context-Free Grammars and PDAs in Theory of Computation, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Context-Free Grammars and PDAs PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Context-Free Grammars and PDAs in GATE CSE

Context-Free Grammars and PDAs has 26 GATE CSE PYQs across 17 papers from 2011 to 2026. 9 of them are 2-mark MCQs like this one, and GATE CSE 2023 has 2.

How GATE tests Context-Free Grammars and PDAs

More from GATE CSE 2023

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2023 · Q40 · MCQ

Consider the pushdown automaton (PDA) P below, which runs on the input alphabet {a, b}, has stack alphabet { , A}, and has three states {s, p, q}, with s being the start state. A transition from state u to state v, labelled c/X/ , where c is an input symbol or , X is a stack symbol, and is a string of stack symbols, represents the fact that in state u, the PDA can read c from the input, with X on the top of its stack, pop X from the stack, push in the string on the stack, and go to state v. In the initial configuration, the stack has only the symbol in it. The PDA accepts by empty stack. Which one of the following options correctly describes the language accepted by P?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.