GATE 2010 CS (CS1) – Question 49
Which regular expression denotes all binary strings with an even number of ones?
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.