GATE | GATE-CS-2009 | Question 11



S -> aSa|bSb|a|b; The language generated by the above grammar over the alphabet {a,b} is the set of
(A) All palindromes
(B) All odd length palindromes.
(C) Strings that begin and end with the same symbol
(D) All even length palindromes


Answer: (B)

Explanation: The possible palindrome generated by above grammar can be of odd length only as there is no rule for S -> \epsilon

For example generated palindromes are aba, aaa, bab, ababa, aaaaa, ..

Quiz of this Question



My Personal Notes arrow_drop_up

Article Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.