Skip to content
Official PYQ · 2010

GATE CS 2010 Q39 — Regular Expressions and Finite Automata

Explain with AI

Let L={w∈ (0+1)∗∣w has even number of 1s}L=\{ w \in \:(0+1)^* \mid w\text{ has even number of }1s \}. i.e., LL is the set of all the bit strings with even numbers of 11s. Which one of the regular expressions below represents LL?

Choose one option
View worked solution

Answer: B

The language LL contains all binary strings with an even number of 11s (including zero 11s, i.e., 0,00,000,…0, 00, 000, \dots).

  • Option A: (0∗10∗1)∗(0^*10^*1)^* cannot generate the string 00, which belongs to LL because it has zero 11s (an even number).
  • Option C: 0∗(10∗1)∗0∗0^*(10^*1)^*0^* cannot generate the string 10101011010101 (which has four 11s). In (10∗1)∗(10^*1)^*, any two consecutive iterations result in 10a110b110^a110^b1, meaning the second and third 11s must be adjacent with no 00 between them.
  • Option D: 0∗1(10∗1)∗10∗0^*1(10^*1)^*10^* requires at least two 11s, so it cannot generate 00.
  • Option B: 0∗(10∗10∗)∗0^*(10^*10^*)^* correctly generates all strings with an even number of 11s. Any string with 2k2k ones can be partitioned as 0n0(10n110n2)(10n310n4)…(10n2k−110n2k)0^{n_0} (1 0^{n_1} 1 0^{n_2}) (1 0^{n_3} 1 0^{n_4}) \dots (1 0^{n_{2k-1}} 1 0^{n_{2k}}), which perfectly matches this regular expression.

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

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