[Math] Find push down automata and context free grammar

automatacontext-free-grammar

I have the following language:
$$
L = \{a^nb^{2n+1} \mid n \ge 0\}
$$

I must find the push down automaton and a context free grammar for the language.

For the push down I have no idea how to approach the problem.

For the context free grammar I think I know the solution:
$$
S \rightarrow Sb \\
S \rightarrow aSbb \\
S \rightarrow \lambda
$$

Best Answer

Here's the basic idea: Start by pushing a marker on the stack. Then, as long as the input character is $a$, push two markers on the stack. Then, for each $b$ read, pop a marker from the stack. If, after having read all the input, the stack is empty, then accept the input.

I've left it to you to complete this PDA to deal with, for example, incorrect inputs like $aba$ and $abbbb$.

Related Question