GATE Computer ScienceHardGATE CS

Which regular expression over {0,1} denotes exactly the set of strings that do not contain two consecutive 1s?

  1. A. (0 + 10)*1*
  2. B. (0*1)*0*
  3. C. (0 + 01)*(ε + 1)
  4. D. (0 + 10)*(ε + 1)

Correct answer: D. (0 + 10)*(ε + 1)

Every 1 except a possible final one must be followed by a 0, so the string is a sequence of blocks 0 or 10, optionally ending with a lone 1. The option with 1* wrongly allows 11, (0*1)*0* allows 11, and (0 + 01)* misses strings like 10.

More Theory of Computation questions

Exams that ask this topic