The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
55 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 in Theory of Computation by (43 points)
edited by | 55 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.

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 (14.3k points)
selected by


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

36,164 questions
43,621 answers
124,008 comments
42,881 users