27 27 votes In the context-free grammar below, $S$ is the start symbol, $a$ and $b$ are terminals, and $\epsilon$ denotes the empty string.$S \rightarrow aSa \mid bSb \mid a \mid b \mid \epsilon$Which of the following strings is NOT generated by the grammar?$aaaa$$baba$$abba$$babaaabab$ Theory of Computation gateit-2006 theory-of-computation context-free-language easy + – Ishrat Jahan 6.7k views answer comment Share Follow Print See all 3 Comments 3 3 Comments reply KUSHAGRA गुप्ता commented Dec 5, 2019 reply Follow flag Even if someone don't observe the given grammar as palindromes. Go with options. $\\ A:S\rightarrow aSa\rightarrow aaSaa\rightarrow aaaa\\ C:S\rightarrow aSa\rightarrow abSba\rightarrow abba\\ D:S\rightarrow bSb\rightarrow baSab\rightarrow babSbab\rightarrow babaSabab\rightarrow babaaabab$ Ans:B 3 3 replyShare Arnav Singh_01 commented Nov 25, 2024 reply Follow flag Even if someone didn't observe palindrome they can atleast observe that starting and ending symbol will be same and only 1 option lacks that which is option B 0 0 replyShare ritiksri8 commented Dec 23, 2024 reply Follow flag With last two symbols we can check and compare whether string can be generated or not.. 0 0 replyShare Please log in or register to add a comment.
Best answer 44 44 votes $L(G) = PALINDROME $ $baba$ does not belong to palindrome , so B is the answer. Praveen Saini answered Mar 2, 2015 • edited Jun 15, 2018 by Milicevic3306 Praveen Saini comment Share Follow See all 2 Comments 2 2 Comments reply Shubham Aggarwal commented Dec 2, 2018 reply Follow flag ya baab belong to the string baba not . 0 0 replyShare ayushsomani commented Dec 3, 2019 reply Follow flag $L\left ( G \right ) =$ Start and end with same symbol Edit:- My Bad. It is Palindrome. 0 0 replyShare Please log in or register to add a comment.
0 0 votes S → aSa | bSb | a | b | ϵ Given string accepts all palindromes. Option B → baba is not palindrome. So, this is not accepted by S. varunrajarathnam answered Sep 3, 2020 varunrajarathnam comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes Grammar is generating strings like L = {$(ab)^{n}.(ba)^{n}$ | $(ba)^{n}.(ab)^{n}$ | $(a)^{n}.(a)^{n}$ | $(b)^{n}.(b)^{n}$ } so $baba$ is not accepted. B shashankrustagi answered Jan 10, 2021 shashankrustagi comment Share Follow See 1 comment 1 1 comment reply anon1 commented Jul 14, 2021 reply Follow flag Your language is not generating “abbbbba” which is a palindrome and should be there inside the language. 0 0 replyShare Please log in or register to add a comment.