Give a regular expression for each of the following sets:
a) set of all string of 0s and 1s beginning with 0 and end with 1.
b) set of all string of 0s and 1s having an odd number of 0s.
d) set of all string of 0s and 1s containing at least one 0.
e) set of all string of a's and b's where each a is followed by two b's.
f) set of all string of 0s and 1s containing exactly two 0s.
a) set of all string of 0s and 1s beginning with 0 and end with 1.
Regular expression will be 0(0 + 1)*1.
It will starts with 0 and ends with 1. In between then any numbe of occurance 0 or 1 can occur
b) set of all string of 0s and 1s having an odd number of 0s.
Regular expression will be 1*0 (1 + 01*0)*
Here any number of 1's can be possible and then one 0 possible. In parentheses also 2 0's are there. So, total odd zero's possible.
d) set of all string of 0s and 1s containing at least one 0.
Regular expression will be (0 + 1)*0(0 + 1)*
Any number of 0's and 1's can be possible but one 0 is must.
e) set of all string of a's and b's where each a is followed by two b's.
Regular expression will be b*(abb)*b*
When a comes, there are 2 b's must.
f) set of all string of 0s and 1s containing exactly two 0s.
Regular expression will be 1*01*01*
Any number of 1's can possible but exactly 2 0's
Get Answers For Free
Most questions answered within 1 hours.