Which one of the following languages over the alphabet {0,1} is described by…
2009
Which one of the following languages over the alphabet {0,1} is described by the regular expression: (0+1)*0(0+1)*0(0+1)* ?
- A.
The set of all strings containing the substring 00.
- B.
The set of all strings containing at most two 0’s.
- C.
The set of all strings containing at least two 0’s.
- D.
The set of all strings that begin and end with either 0 or 1.
Attempted by 151 students.
Show answer & explanation
Correct answer: C
Key insight: the regular expression requires two occurrences of the symbol 0, but those two 0s need not be adjacent.
The prefix (0+1)* can be any string (including empty).
Then a 0 enforces the first occurrence of the symbol 0.
The middle (0+1)* can be any string (including empty), so the second 0 may be adjacent to the first or separated by other symbols.
Then a second 0 appears, and the final (0+1)* allows any trailing string.
Because the two 0s need not be consecutive, the expression matches strings with at least two 0s. For example, "010" matches the expression but does not contain the substring "00".
The set of all strings containing the substring 00. — Incorrect because the regex allows the two zeros to be separated (example: "010").
The set of all strings containing at most two 0’s. — Incorrect because the regex permits more than two zeros (example: "000").
The set of all strings containing at least two 0’s. — Correct: the regex requires two 0s somewhere in the string, so it describes exactly the strings with at least two 0s.
The set of all strings that begin and end with either 0 or 1. — Incorrect because this describes (non-empty) strings independent of the number of 0s; the regex specifically requires at least two 0s.
A video solution is available for this question — log in and enroll to watch it.