Which one of the following regular expressions represents the set of all binary strings with an odd number of 1's?

A.

((0 + 1)*1(0 + 1)*1)*10*

B.

(0*10*10*)*0*1

C.

10*(0*10*10*)*

D.

(0*10*10*)*10*

Solution:

Option A: ((0 + 1)*1(0 + 1)*1)*10*
This regular expression cannot generate 001 or 01 string (odd no. f 1's)

Option B: (0*10*10*)*0*1
This regular expression cannot generate 100 or 10 strings (odd no. of 1's)

Option C: 10*(0*10*10*)*
This regular expression cannot generate 001 or 01 string (odd no. of 1's)

Option D: (0*10*10*)*10*
This regular expression cannot generate 001 or 01 string (odd no. of 1's)

 

None of the above options can generate strings with an odd number of 1's. In the exam, marks were given to all.