recategorized by
1,171 views
2 votes
2 votes

A regular expression for accepting strings with exactly one $1$ more than $0$’s is

  1. $0^{\ast}1$
  2. $(0|1)^{\ast}1(0|1)^{\ast}$
  3. $(0|1)^{\ast}1(0|1)^{\ast}|1(0|1)^{\ast}$
  4. Not possible
recategorized by

1 Answer

2 votes
2 votes

The condition is there should be one 1 more than 0 in the language. So, the language of the strings would be:

{1,011,110,101,00111,….}

Now lets see each option:

  1. 0*1:  Here, * can produce any number of 0’s ie 001 will also be generated by this regex which is not part of our language – False
  2. (0+1)*1(0+1)*: Here, we can have strings like 010 which is not the part of our language – False
  3. (0+1)*1(0+1)* + 1(0+1)*- Here also we can have strings like 010, 100,… -False

Hence, answer should be option D.

Also, 

We can think as for generating this language, we would need to remember the number of 0’s which needs memory. So, cannot be done by a dfa. We need a PDA for it

Hence, option D

Related questions

0 votes
0 votes
0 answers
1
rsansiya111 asked Dec 8, 2021
242 views
0 votes
0 votes
0 answers
2
rsansiya111 asked Dec 8, 2021
385 views
0 votes
0 votes
0 answers
3
rsansiya111 asked Dec 8, 2021
168 views
0 votes
0 votes
1 answer
4
rsansiya111 asked Dec 8, 2021
352 views