The GATE Grind

GATE 2010 CS (CS1) – Question 49

Theory of Computation · Regular Expressions and Finite Automata · 2 marks · Multiple choice

Which regular expression denotes all binary strings with an even number of ones?

  1. (0*10*1)*
  2. 0*(10*10*)*
  3. 0*(10*1)*0*
  4. 0*1(10*1)*10*

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (B) 0*(10*10*)*

Explanation

In B, leading zeros are arbitrary and each repeated block contributes exactly two ones with arbitrary zeros between and after them. Every even-one string can be split this way, including strings containing only zeros. A misses some trailing zeros; C restricts zeros between successive pairs. D does not cover the zero-one case. Thus B.

More Regular Expressions and Finite Automata questions

All Regular Expressions and Finite Automata questions →