Reputation: 1732
I have a simple question about finding a regular expression for a given language.
I am given the language L where:
L = {w ∈ {0, 1}* : w has exactly one pair of consecutive zeros}
My first attempt at this was to try L( (0 + 1)* 00 (0 + 1)*), but I noticed the problem with that would be with where I have (0 + 1)* because if 0 is chosen, it can be zero more more of them, thus leading to more than one pair of consecutive zeros.
I also know, that the possible cases I have are, two zeros in the front, in the middle, and at the end. I just am not quite sure how to create a regular expression for that.
Any help is much appreciated.
Upvotes: 6
Views: 6516
Reputation: 1
It is wrong try 00110011 it must not be Satisfied But here it is satisfying Take firstly the pair 00 then take 110 Then take 011 So in whole it would be 00110011 that it is satisfying so it is wrong
Upvotes: -1
Reputation: 667
My answer would be : (1 + 01) 00 (1 + 10)**
Explanation:
The consecutive zeros shouldn't be preceded or followed by another zero. Hence 00 should be preceded by a 1 which can be either a 1 or 01. It can be followed by a 1 or 10.
Upvotes: 0
Reputation: 1733
The best possible answer for this problem is (1 + 01)* 00 (1 + 10)*
Upvotes: 3
Reputation: 655489
Try this:
1* (011*)* 00 (11*0)* 1*
An explanation:
Upvotes: 8
Reputation: 273636
The sequence:
Upvotes: 0