GATE / CS ARCHIVE

GATE CSE 1997 / QUESTION 6.4

Regex avoiding100

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

GATE 1997, Q6.4 2 marks · MCQ
Report issue

Regular Expressions & Languages

Question 6.4, GATE 1997: Which regex describes binary strings with no substring 100? Choice D is 0*(10+1)*.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Any leading run of zeros is harmless and is covered by 0*. After the first 1, there cannot be two consecutive zeros, or the preceding 1 followed by those zeros would form 100. Thus the remaining word can be partitioned into blocks 1 and 10, covered by (1+10)*. Conversely, a word built this way has no pair of zeros after a 1, so it cannot contain 100. Hence 0*(10+1)* is exactly the desired language, D. It includes ε and all-zero strings, which also avoid the forbidden substring.

Original paper, page 5