75.7k views
4 votes
Write a regular expression of the language havingstrings that either start or end with "00" and have nomore zeroes. Where the alphabet is {0,1}.

User Cedriga
by
7.8k points

1 Answer

5 votes

Answer:

001*|1*00

Step-by-step explanation:

The language consists of strings in {0,1} that either start with 00 or end with 00 and have no more zeros.

The requirement can be divided into two parts:

1) Strings that start with 00 and have no more zeros

2) Strings that end with 00 and have no more zeros

Generating regular expressions for these parts:

1) 001* - starts with two zeros and can have zero or more 1s later

2)1*00 - starts with zero or more 1s and ends with two zeros

So on combining with the or operator(|), the overall regular expression for the strings in the language becomes:

001*|1*00

User Barsoap
by
8.8k points