1 votes 1 votes Give a context-free grammar for the language below : (n>=0, m>=0) L= { w ∊ {a,b}* : na(w)=2nb(w)+1} Theory of Computation theory-of-computation grammar + – Ayush Upadhyaya asked Mar 19, 2017 Ayush Upadhyaya 2.1k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes $$\begin{align*} &S\rightarrow aA\;|\;Aa \\ &A\rightarrow aAbAa\;|\;aaAb\;|\;bAaa\;|\;AA\;|\;\epsilon \end{align*}$$ dd answered Mar 19, 2017 dd comment Share Follow See all 4 Comments See all 4 4 Comments reply Ayush Upadhyaya commented Mar 20, 2017 reply Follow Share Could you please explain the base case of this solution? 0 votes 0 votes kdkha commented Sep 26, 2018 reply Follow Share Hello, I was wondering if you ever found out the solution to this problem? 0 votes 0 votes prashant jha 1 commented Sep 22, 2019 reply Follow Share This solution is not correct since the string baaaaab is not derived here. 2 votes 2 votes JAINchiNMay commented Oct 10, 2020 reply Follow Share the strings starting and ending with b can never be achieved 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes I think it will work for all cases $S\rightarrow aA|Aa|AaA$ $A\rightarrow \varepsilon |aaAb|bAaa|aAbAa$ Yamini Cherukuri answered Jun 2, 2023 Yamini Cherukuri comment Share Follow See all 0 reply Please log in or register to add a comment.