1
43kviews
Construct a CFG to over {a,b} to accept a set of all palindromes
1 Answer
2
5.4kviews

Sample strings for palindromes:

abba

baab

bbbb

aaaa

So, our CFG has to provide a looping condition such that the palindrome is constructed

S =>abSBA|baSAB|ε

A =>a

B =>b

We break this grammar even more to simplify it further

We can do so by having more non-terminals involved in …

Create a free account to keep reading this post.

and 2 others joined a min ago.

Please log in to add an answer.