+1 vote
81 views

find regular expression over $\{a,b\}$ corresponding to "set of strings containing Exactly $2a's$.".

I have come up with two answers and are seeming Logically correct to me. Please correct me If I am wrong.

1. $b^* a b^* a b^*$ --- This will have $0$ or any number of $b's$ at start and $0$ or any number of $b's$ in the middle and $0$ or any number of $b's$ at the end .... So it should cover all the Strings in the Language.

2. $a a b^* + a b^* a + b^* a a$ -- This contains the three scenarios where the two $a's$ are at start, one $b$ In the middle of $2 a's$ and $2 a's$ at the end.

I am wondering if both of them are correct.

Thanks in advance.

asked
edited | 81 views
+2

1st one is Right.

But Second one is not ,because using Second Definition we can not find all our required Strings....Such as we can not get String babab from  Second one.

0 votes
Best answer

• ## Second one is wrong becz it is not gives string like baab,babab.

answered by Boss (33.6k points)
selected

0 votes
2 answers
2
0 votes
1 answer
5
0 votes
1 answer
6
0 votes
0 answers
7