Discussion
Which one of the following regular expressions represents the language: the set of all binary strings having two consecutive 0s and two consecutive 1s?
Answer: B
The regular expression is \((0+1)^{*}(00(0+1)^{*}11 + 11(0+1)^{*}00)(0+1)^{*}\).
A string with both a 00 and a 11 has one of them occurring first. So it is: anything, then 00, then anything, then 11, then anything; or the same with 11 first. The middle \((0+1)^{*}\) lets the two pairs be separated, and the outer ones allow any prefix and suffix. That is exactly this expression.
The 0011/1100 option forces the pairs to be adjacent, missing strings such as 001011, where the pairs are separated. The option joined by '+' with \((0+1)^{*}00(0+1)^{*}\) accepts strings with only 00 or only 11. The last option forces the string to start and end with the pairs, missing 100110.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development