Write a regular expression for the set of string that consists of alternating 0’s and 1’s.


A regular expression for the set of string that consists of altering 0’s and 1’s. For this we have to consider some steps, they are:
Step-1: To get all string that being with 0 and end 1. We can use the regular expression (01)*.
Step-2: To get all string that begin with 1 and end with 0. We can use the expression (10)*.
Step-3: To get the set of all string that both being and end with 0 we can use the regular expression 0(10)*.
Step-4: To get the set of all string that both being and end with 1 we can use the regular expression 1(01)*.
Then, the entire regular expression that is the set of string consists of alternatives 0’s and 1’s.
(01)* + (10)* + 0(10)* + 1(01)*
Here, we use ‘+’ operator to take the union of four language that together gives us all the strings with alternating 0’s and 1’s.

No comments

Dear Members, Thanks for Your Comments. We must be reply your comment answer as soon as possible. Please Stay with us.....

Theme images by ideabug. Powered by Blogger.