Skip to content
Official PYQ · 2023

GATE CS 2023 Q30 — Context-free Grammars and Push-down Automata

Explain with AI

Consider the pushdown automaton (PDA)  P\text{(PDA)}\;P below, which runs on the input alphabet {a,b}\{a, b\}, has stack alphabet {⊥,A}\{\perp, 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 ϵ,X\epsilon, X is a stack symbol, and γ\gamma is a string of stack symbols, represents the fact that in state uu, the (PDA)\text{(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 ⊥\perp in it. The (PDA)\text{(PDA)} accepts by empty stack.

Which one of the following options correctly describes the language accepted by P?P ?

Choose one option
View worked solution

Answer: A

To find the language accepted by the PDA PP by empty stack, let us trace the transitions step-by-step:

  • State ss (Pushing AA's): The self-loops on state ss are a,⊥/A⊥a, \perp / A\perp and a,A/AAa, A / AA. This means for every input symbol aa, one AA is pushed onto the stack. To push any AA and proceed, we must read at least one aa, so m≥1m \ge 1. After reading ama^m, the stack contains Am⊥A^m \perp.
  • Transition to state pp (Reading bb's): The transition from ss to pp is b,A/ϵb, A / \epsilon, and the self-loop on pp is b,A/ϵb, A / \epsilon. This means we must read at least one bb to leave state ss, which implies n≥1n \ge 1. Each bb read pops one AA from the stack. After reading bnb^n, the stack has Am−n⊥A^{m-n} \perp.
  • Transition to state qq (Emptying the stack): The transition from pp to qq is ϵ,A/ϵ\epsilon, A / \epsilon. This is an ϵ\epsilon-transition that pops an AA without consuming any input. For this transition to be valid, there must be at least one AA remaining on the stack after reading all bb's. This requires: m−n≥1  ⟹  n<mm - n \ge 1 \implies n < m
  • State qq: Once in state qq, the self-loop ϵ,A/ϵ\epsilon, A / \epsilon pops any remaining AA's, and the transition ϵ,⊥/ϵ\epsilon, \perp / \epsilon pops the bottom-of-stack marker ⊥\perp, emptying the stack and accepting the string.

Combining these conditions, we get 1≤m1 \le m and n<mn < m. Thus, the accepted language is:

{ambn∣1≤m and n<m}\left\{a^{m} b^{n} \mid 1 \leq m \text{ and } n < m\right\}

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Context-free Grammars and Push-down Automata questions