asked 110k views
0 votes
Construct the context free grammar G and a Push Down Automata (PDA) for each of the following Languages which produces L(G). i. L1 (G) = m >0 and n >0. ii. L2 (G) = 01m2m3n

1 Answer

1 vote

Answer:

For language L1 (G) = am bn , a context-free grammar can be constructed as follows: S → aSb | X, X → bXc | ε. Here, S is the starting nonterminal, and the grammar generates strings of the form am bn, where m and n are greater than zero.

To construct a pushdown automaton (PDA) for L1 (G), we can use the following approach. The automaton starts in the initial state with an empty stack. For every 'a' character read, we push it onto the stack. For every 'b' character read, we pop an 'a' character from the stack. When we reach the end of the input string, if the stack is empty, the input string is in L1 (G).

For language L2 (G) = m>0, n >0, a context-free grammar can be constructed as follows: S → 0S123 | A, A → 1A2 | X, X → 3Xb | ε. Here, S is the starting nonterminal, and the grammar generates strings of the form 01m2m3n, where m and n are greater than zero.

To construct a pushdown automaton (PDA) for L2 (G), we can use the following approach. The automaton starts in the initial state with an empty stack. For every '0' character read, we push it onto the stack. For every '1' character read, we push it onto the stack. For every '2' character read, we pop a '1' character and then push it onto the stack. For every '3' character read, we pop a '0' character from the stack. When we reach the end of the input string, if the stack is empty, the input string is in L2 (G).

Step-by-step explanation:

answered
User Tyreek
by
8.1k points