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

The Gateway to Computer Science Excellence

First time here? Checkout the FAQ!

x

0 votes

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.

- All categories
- General Aptitude 1.3k
- Engineering Mathematics 5.2k
- Digital Logic 2k
- Programming & DS 3.7k
- Algorithms 3.2k
- Theory of Computation 4k
- Compiler Design 1.6k
- Databases 3k
- CO & Architecture 2.6k
- Computer Networks 3k
- Non GATE 1k
- Others 1.3k
- Admissions 486
- Exam Queries 435
- Tier 1 Placement Questions 18
- Job Queries 56
- Projects 9

36,164 questions

43,621 answers

124,008 comments

42,881 users