Which of the following regular expressions describes the language over {0, 1}…
2008
Which of the following regular expressions describes the language over {0, 1} consisting of strings that contain exactly two 1's?
- A.
(0 + 1) * 11(0 + 1) *
- B.
0 * 110 *
- C.
0 * 10 * 10 *
- D.
(0 + 1) * 1(0 + 1) * 1 (0 + 1) *
Attempted by 54 students.
Show answer & explanation
Correct answer: C
The correct regular expression must match strings over {0, 1} that contain exactly two 1's. Option C (0*10*10*) ensures this by allowing any number of 0's before the first 1, between the two 1's, and after the second 1. This guarantees exactly two 1's with any number of 0's in between and around them. Other options either allow more than two 1's or restrict the placement of 1's too strictly.
A video solution is available for this question — log in and enroll to watch it.