2 votes 2 votes input {a,b} Write R.E where every b is followed by at least 2 K a's? (K is +ve integer) Theory of Computation regular-expression + – iarnav asked Aug 29, 2017 iarnav 1.1k views answer comment Share Follow See all 9 Comments See all 9 9 Comments reply Show 6 previous comments iarnav commented Aug 30, 2017 reply Follow Share @LeenSharma - Thanks you're awesome! Jus' a little doubt, from your updated RegEx can we make generate any no of a's like aaaaa (5a's) 0 votes 0 votes LeenSharma commented Aug 30, 2017 reply Follow Share yes we can. 0 votes 0 votes Harsh Choudhary commented Nov 12, 2017 reply Follow Share (a*b(aa)+ + a)* for (a0b(aa)1 + a)1 one of the string will be baaa .i.e not multiple of 2 0 votes 0 votes Please log in or register to add a comment.
Best answer 1 votes 1 votes The regular expression will be (a+b((aa) k)+) * Rishabh Agrawal answered Aug 29, 2017 • selected Jan 14, 2018 by iarnav Rishabh Agrawal comment Share Follow See all 9 Comments See all 9 9 Comments reply iarnav commented Aug 30, 2017 reply Follow Share @Rishabh Agrawal This seems to be correct, can you please verify it? 0 votes 0 votes Rishabh Agrawal commented Aug 30, 2017 reply Follow Share As the question says every bis followed by atleast 2k a lets assume k=1. so every b will be followed by atleast 2 a. the language will be L={a,aa,aaa.....,baa,baaa,baab.....} After b there is always atleast 2a and after that a could appear any number of times.So if you want to produce baaa from my R.E then (a+b((aa) )+) (a+b((aa) )+) Take one occurence of aa from first set of brackets and only a from second bracket. You will get baaa as string. Hope this helps. 1 votes 1 votes iarnav commented Aug 30, 2017 reply Follow Share Is this RegEx a*(b(aa)^+)*+a* correct too? 0 votes 0 votes LeenSharma commented Aug 30, 2017 reply Follow Share I did one mistake there. This R.E. is also correct R.E. : - $(a^{*}b(aa)^{+}+a)^{*}$ 0 votes 0 votes Rishabh Agrawal commented Aug 30, 2017 reply Follow Share @iarnav No,it will not generate baaa but it is valid string for k=1. 0 votes 0 votes iarnav commented Aug 30, 2017 i edited by iarnav Aug 30, 2017 reply Follow Share @Rishabh Agrawal Yeah, man baaa can't be generated by @LeenSharma RegEx mine RegEx. @LeenSharma Paaji what you say? 0 votes 0 votes LeenSharma commented Aug 30, 2017 reply Follow Share From this R.E. $(a^{*}b(aa)^{+}+a)^{*}$ you can generate string baaa. 0 votes 0 votes iarnav commented Aug 30, 2017 reply Follow Share @LeenSharma Yes, you're right. I figured it out y putting whole *=2 P.S - is there a way to solve these questions? Can you share some tips, please? 0 votes 0 votes LeenSharma commented Aug 30, 2017 reply Follow Share $(a^{*}b(aa)^{+}+a^{*})^{*}$ and $(b(aa)^{+}+a)^{*}$ is also correct. 1 votes 1 votes Please log in or register to add a comment.
0 votes 0 votes i got a* (bb*a) (bb*a)* a (b (bb*a) + a)* this is my ans suryaprakash answered Jan 14, 2018 suryaprakash comment Share Follow See 1 comment See all 1 1 comment reply suryaprakash commented Jan 14, 2018 reply Follow Share sry i did see 2k a's, but for 2 a's my answer would be correct 0 votes 0 votes Please log in or register to add a comment.