You are not logged in.
Pages: 1
Create a context-free grammar that generates the language a^nb^(n+m)c^m.
I came up with this so far:
S -> aAc
A -> bb
But this only does the case with abbc. Can anyone help with this one?
Offline
You're on the right track, but notice that your grammar requires an equal amount of a's and c's. What you need is a grammar that produces an equal amount of a's and b's at first, then changes to produce an equal amount of b's and c's. I'll start you off:
S -> aAb
S -> B
S -> empty
A -> aCbB
A -> empty
I'll leave B and C to you.
Wrap it in bacon
Offline
Pages: 1