1,029 views
2 votes
2 votes
In Regular Expressions I saw

(a+b)* = (a*b*)*

Now my question is how (a*b*)* is able to generate 'ba' string (or any string in which 'a' comes after 'b')

1 Answer

Best answer
5 votes
5 votes
(a*b*)* means that to we can take 'a' any number of times, then we can take 'b' any number of times, and then we can keep repeating this process any number of times. Here 'any number of times' also includes zero times.

Here is how one can generate the required string:

$(a^{*}b^{*})^{*} \rightarrow (a^{*}b^{*})^{2} \rightarrow  (a^{*}b^{*})(a^{*}b^{*}) \rightarrow  (a^{0}b^{1})(a^{1}b^{0}) \rightarrow  (b)(a) \rightarrow  ba$.

:)
selected by

Related questions

1 votes
1 votes
2 answers
3