Is the grammar for the language $L = \{ a^nb^mc^n \mid n,m \geqslant 0 \}$ correct?

105 Views Asked by At

I was doing this grammar.

The language $L = \{ a^nb^mc^n \mid n,m \geqslant 0 \}$

I wanted to know if it is correct or not.

This is my solution

$S \to aSc\mid B \mid e$

$B \to bB \mid e$

1

There are 1 best solutions below

1
On BEST ANSWER

Your grammar is correct. You could save one rule if you wish:

$S \to aSc + B$

$B \to bB + e$