66 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.

edited | 66 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.