in Theory of Computation retagged by
84 views
0 votes
0 votes
Give a context-free grammar for the set of all strings over the alphabet {a, b} with exactly twice as many a’s as b’s. Explain the working of the grammar by characterizing the strings generated by each non-terminal.
in Theory of Computation retagged by
84 views

1 Answer

2 votes
2 votes

$S\rightarrow aSaSb|aSbSa|bSaSa|SS|\varepsilon$

It's from Sipser