GateAI
Context-Free Grammars and PDAs

GATE CSE 2015 Set 1 · Q51

MCQ2 marksMedium

Time

Consider the NPDA (Q={q0,q1,q2},Σ={0,1},Γ={0,1,⊥},δ,q0,⊥,F={q2})(Q = \{q_0, q_1, q_2\}, \Sigma = \{0, 1\}, \Gamma = \{0, 1, \bot\}, \delta, q_0, \bot, F = \{q_2\}), where (as per usual convention) QQ is the set of states, Σ\Sigma is the input alphabet, Γ\Gamma is the stack alphabet, δ\delta is the state transition function, q0q_0 is the initial state, ⊥\bot is the initial stack symbol, and FF is the set of accepting states. The state transition is as follows: Which one of the following sequences must follow the string 101100 so that the overall string is accepted by the automaton?

GATE CSE 2015 Set 1 Q51 diagram

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: B) 10010

Context-Free Grammars and PDAs

Let us trace the operation of the given Non-deterministic Pushdown Automaton (NPDA):

  1. In state q0q_0, every input bit (00 or 11) is pushed onto the stack on top of whatever symbol is present.

  2. The transition from q0q_0 to q1q_1 can be taken non-deterministically on input 00, 11, or ϵ\epsilon, without changing the stack symbol (Z→ZZ \to Z).

  3. In state q1q_1, reading a 00 pops a 11 from the stack (0,1Z→Z0, 1Z \to Z), and reading a 11 pops a 00 from the stack (1,0Z→Z1, 0Z \to Z).

  4. Once the stack is cleared down to ⊥\bot, the automaton moves to accepting state q2q_2 via the ϵ\epsilon-transition ϵ,⊥→ϵ\epsilon, \bot \to \epsilon.

Given the input prefix 101100:

  • If the first 55 characters 10110 are processed in state q0q_0, the stack (from bottom to top above ⊥\bot) contains: 1, 0, 1, 1, 0 (with top of the stack being 0).

  • The 6th6^{\text{th}} character 0 is consumed during the transition q0→q1q_0 \to q_1 via the transition 0,Z→Z0, Z \to Z.

  • In state q1q_1, to pop the remaining symbols from top to bottom (0, 1, 1, 0, 1), the automaton requires the complement of each symbol in order:

    • Top 0 requires input 1 (pops 0)

    • Next 1 requires input 0 (pops 1)

    • Next 1 requires input 0 (pops 1)

    • Next 0 requires input 1 (pops 0)

    • Next 1 requires input 0 (pops 1)

Thus, the string that must follow is 10010, corresponding to option (B).

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 Q51 of the GATE CSE 2015 Set 1 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 it is the only one in GATE CSE 2015 Set 1.

How GATE tests Context-Free Grammars and PDAs

More from GATE CSE 2015 Set 1

Share this solution

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

GateAI solution cardGATE CSE 2015 Set 1 · Q51 · MCQ

Consider the NPDA (Q = {q0, q1, q2}, = {0, 1}, = {0, 1, }, , q0, , F = {q2}), where (as per usual convention) Q is the set of states, is the input alphabet, is the stack alphabet, is the state transition function, q0 is the initial state, is the initial stack symbol, and F is the set of accepting states. The state transition is as follows: Which one of the following sequences must follow the string 101100 so that the overall string is accepted by the automaton?

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.