33 33 votes Consider the CFG with $\left\{S, A, B\right\}$ as the non-terminal alphabet, $\{a, b\}$ as the terminal alphabet, $S$ as the start symbol and the following set of production rules:$S \rightarrow aB$ $S \rightarrow bA$$B \rightarrow b$ $A \rightarrow a$ $B \rightarrow bS$ $A \rightarrow aS$$B \rightarrow aBB$ $A \rightarrow bAA$Which of the following strings is generated by the grammar?$aaaabb$$aabbbb$$aabbab$$abbbba$ Compiler Design gatecse-2007 compiler-design grammar normal + – Kathleen 15.6k views answer comment Share Follow Print See all 8 Comments 8 8 Comments reply ST commented Sep 15, 2016 reply Follow flag S -> aA ...from where ? 0 0 replyShare LeenSharma commented May 23, 2017 reply Follow flag how did you get 3rd step from the second step?? 0 0 replyShare Ahwan commented May 23, 2017 reply Follow flag Hm. Sorry. I did not notice bS is not present in production. 1 1 replyShare Chhotu commented Jan 1, 2018 reply Follow flag Grammar(DCFL) for generating equal number of $a's$ and $b's$. Excluding $\epsilon$. 2 2 replyShare dragonball commented Jan 29, 2018 reply Follow flag Just check for equal no of a's and b's . 1 1 replyShare mohan123 commented Sep 23, 2019 reply Follow flag option C "aabbab" 3 3 replyShare ByteCode commented Dec 10, 2023 reply Follow flag This method would work in single correct but not multiple correct 0 0 replyShare razvardhan commented Dec 31, 2024 reply Follow flag This grammar is ambigous. 0 0 replyShare Please log in or register to add a comment.
Best answer 41 41 votes $S \rightarrow aB$ $ \rightarrow aaBB$ $ \rightarrow aabB$ $ \rightarrow aabbS$ $ \rightarrow aabbaB$ $ \rightarrow aabbab$ Correct Answer: $C$ Arjun answered Dec 22, 2014 • edited Apr 29, 2019 by Naveen Kumar 3 Arjun comment Share Follow See all 6 Comments 6 6 Comments reply Show 3 previous comments Praveen Saini commented Jan 2, 2016 reply Follow flag No it is one grammar having all these productions as S->aB s->bA, can be written as S->aB|bA we need to find which of the given string can be derived by Grammar. and then for that string , how many different derivations are possible 7 7 replyShare Nit9 commented Jan 2, 2016 reply Follow flag thanks, i was confused that how could s-> bA lead to aabbab 0 0 replyShare Abhineet Singh commented Nov 28, 2020 reply Follow flag is there a typo here? geeks for geeks has given the grammar like this, also checked some other sites S --> aB S --> bA B --> b A --> a B --> bS A --> aS B --> aBB A --> bAA 0 0 replyShare Please log in or register to add a comment.
0 0 votes Here is the answer Skyquake._ answered Jul 1 Skyquake._ comment Share Follow 0 reply Please log in or register to add a comment.
–3 –3 votes ans c) b) Aditi Dan answered Dec 22, 2014 1 flag: ✌ Edit necessary (js__) Aditi Dan comment Share Follow See 1 comment 1 1 comment reply Prateek kumar commented Aug 28, 2016 reply Follow flag no, you can not generate b) from given grammar if you try to generate b) you will get string "aabbbba" here one "a" at last position is extra you can generate c) only 2 2 replyShare Please log in or register to add a comment.