Reputation: 7547
The problem is to provide context free grammar where L={w∈{a,b}∗∣the number of a's in w is one bigger than the number of b's}.My solution is
S -> LaL
L -> aLb|abL|bLa|Lab|Lba|baL|_
Can anyone tell why my solution doesn't work for this language?
Upvotes: 0
Views: 187
Reputation: 11
Try this.. There might be a better/easier answer but this passes the test of the verifier.
S -> A
A -> BaAbB | BAabB | BabAB | BbaAB | BbAaB | a
B -> bBa | aBb | _
Upvotes: 0