Skip to content
Related Articles
Open in App
Not now

Related Articles

GATE | GATE-CS-2009 | Question 11

Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 08 Oct, 2021
Improve Article
Save Article

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
Related Articles

Start Your Coding Journey Now!