The GATE Grind

GATE 2021 CS – Question 61

Theory of Computation · Context-Free Grammars and Pushdown Automata · 2 marks · Numerical answer

In a pushdown automaton $P=(Q,\Sigma,\Gamma,\delta,q_0,F)$, a transition of the form $p \xrightarrow{a, X \to Y} q$ represents $(q,Y)\in\delta(p,a,X)$. Consider the following pushdown automaton over the input alphabet $\Sigma=\{a,b\}$ and stack alphabet $\Gamma=\{\#,A\}$: $q_0 \xrightarrow{\epsilon,\epsilon\to\#} q_1$; $q_1$ has a self-loop $a,\epsilon\to A$; $q_1 \xrightarrow{\epsilon,\epsilon\to\epsilon} q_2$; $q_2$ has a self-loop $b,A\to\epsilon$; $q_2 \xrightarrow{\epsilon,A\to A} q_3$ where $q_3$ is the accepting state. The number of strings of length 100 accepted by the above pushdown automaton is ______.

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 50

Explanation

Accepted strings are $a^n b^m$ with $m<n$, since the final transition needs at least one A left on the stack. With n+m=100 and m from 0 to 49, there are 50 strings.