The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+1 vote

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 in Theory of Computation by (183 points)
edited by | 81 views

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.

1 Answer

0 votes
Best answer
  • Regular expression for exactlly two a's is b*ab*ab* is right.

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

answered by Boss (33.6k points)
selected by

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,408 questions
53,590 answers
70,871 users