Skip to content
Official PYQ · 1997

GATE CS 1997 Q6.4 — Regular Expressions and Finite Automata

Explain with AI

Which one of the following regular expressions over {0,1}\{0,1\} denotes the set of all strings not containing 100\text{100} as substring?

Choose one option
View worked solution

Answer: D

To find the regular expression for the set of all strings over {0,1}\{0,1\} that do not contain 100100 as a substring:

  1. Analyze the structure: Any such string can start with any number of 00s, which is represented by 0∗0^*.
  2. After the first 11: Once the first 11 appears, we cannot have two consecutive 00s (i.e., 0000 is forbidden after a 11). This means every 00 that appears after the first 11 must be immediately preceded by a 11, forming the block 1010.
  3. Formulate the suffix: Therefore, the remaining part of the string after the first 11 can only be composed of blocks of 11 and 1010. This is represented by the regular expression (10+1)∗(10+1)^*.

Combining these two parts, we get the complete regular expression: 0∗(10+1)∗0^*(10+1)^*.

Why other options are incorrect:

  • Option A: 0∗(1+0)∗0^*(1+0)^* is equivalent to (0+1)∗(0+1)^*, which generates all strings, including 100100.
  • Option B: 0∗1010∗0^*1010^* is extremely restrictive and cannot generate simple valid strings like 1111.
  • Option C: 0∗1∗01∗0^*1^*01^* cannot generate valid strings like 110110110110, which do not contain 100100.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Regular Expressions and Finite Automata questions