GATE / CS ARCHIVE

GATE CSE 2009 / QUESTION 15

Regular expression with two distinguished zeros

Theory of Computation · Regular Expressions & Languages · Full GATE CSE 2009 paper

GATE 2009, Q15 1 mark · MCQ
Report issue

Regular Expressions & Languages

Question 15, GATE 2009: Describe (0+1)*0(0+1)*0(0+1)*: A strings containing 00; B at most two zeros; C at least two zeros; D strings beginning and ending with either 0 or 1.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Each starred(0+1) factor permits any binary string, but the two explicit 0 symbols must occur in order. Hence the expression accepts exactly strings with at least two zeros, not necessarily adjacent, C.

Each explicit 0 in the expression must consume a separate symbol, so every generated string contains at least two zeros. The three starred factors can contain arbitrary binary strings, including more zeros, and may be empty. Conversely, choose any two zeros in a string and assign the prefix, intervening segment and suffix to the three starred factors. The zeros need not be adjacent, so 010 is accepted despite lacking substring 00. Hence C.

Original paper, page 3