29 29 votes Language $L_{1}$ is defined by the grammar: $S_{1} \rightarrow a S_{1} b \mid \varepsilon$ Language $L_{2}$ is defined by the grammar: $S_{2} \rightarrow a b S_{2} \mid \varepsilon$ Consider the following statements: P: $L_{1}$ is regular Q: $L_{2}$ is regular Which one of the following is TRUE? Both $P$ and $Q$ are true. $P$ is true and $Q$ is false. $P$ is false and $Q$ is true. Both $P$ and $Q$ are false. Theory of Computation gatecse-2016-set2 theory-of-computation easy regular-language + – Akash Kanase 12.6k views answer comment Share Follow Print See all 2 Comments 2 2 Comments reply js__ commented Oct 11, 2025 reply Follow flag L1 is generating equal no. of a and b -> CFL L2 is generating (ab)* -> Reg 0 0 replyShare A Ganesh Reddy commented Oct 26, 2025 reply Follow flag Most Simplest Way to Check : L1 = { a^n b^n | n >= 0 } (infinite dependency over 2 symbols ; so non regular) L2 = { (ab)^n | n >= 0 } (here no dependency; so regular) 0 0 replyShare Please log in or register to add a comment.
Best answer 82 82 votes Answer is C. $S_1\rightarrow aS_1b\mid \epsilon$ $L_1 = \{ a^nb^n \mid n\geq 0\}$ is CFL $S_2\rightarrow abS_2\mid \epsilon$ $L_2 = \{ (ab)^n \mid n\geq 0\}$ is Regular having regular expression $(ab)^*$ Praveen Saini answered Feb 12, 2016 • edited Jun 15, 2018 by Milicevic3306 Praveen Saini comment Share Follow See all 3 Comments 3 3 Comments reply iarnav commented Sep 5, 2017 i edited by iarnav Sep 5, 2017 reply Follow flag doubt cleared! 0 0 replyShare chirudeepnamini commented Nov 27, 2019 reply Follow flag Just to add.. We have to be careful while checking This question is asking for checking whether language generated by given grammar are regular or not.. But there are some questions like this : https://gateoverflow.in/3491/gate2007-it-49 Where they ask for checking whether given grammars itself are regular are not.. 6 6 replyShare CheeseCuBES commented Jan 7, 2021 reply Follow flag note: left linear or right linear grammer means regular. So l2 is regular 5 5 replyShare Please log in or register to add a comment.
16 16 votes L2 is Right Linear Grammar L1 is neither right or left linear grammar , A regular language either should be Left or Right linear grammar , but not both so solution is L2 is regular but L1 is not Sandeep Verma answered Nov 20, 2017 Sandeep Verma comment Share Follow See all 3 Comments 3 3 Comments reply chirudeepnamini commented Nov 27, 2019 reply Follow flag @Sandeep Verma There is a small flaw in your answer... The question asks for checking whether language generated by given grammar is regular or not.. We can't eliminate option based on the regularity of grammar.. I mean there are some grammars which are not regular but still produce regular grammar.. For example, S-->aSa/epsilon is not a regular grammar but still it produces a regular grammar aa*. 10 10 replyShare MohanK commented Dec 9, 2020 reply Follow flag But, S-->aSa/epsilon doesn’t have the Regular expression aa*. Since , by using aa*, we can generate the string ‘aaa’. But the grammar S-->aSa/epsilon can’t generate ‘aaa’ . Correct me, If I am wrong. 0 0 replyShare Vijay Devagonda commented Jan 9, 2025 reply Follow flag (aa)* 0 0 replyShare Please log in or register to add a comment.