GATE / CS ARCHIVE

GATE CSE 2020 / QUESTION 7

GATE CSE 2020 Q7

Theory of Computation · Regular Expressions & Languages · Full GATE CSE 2020 paper

GATE 2020, Q7 1 mark · MCQ
Report issue

Regular Expressions & Languages

Question 7, GATE 2020: Which regular expression denotes binary strings with an odd number of 1s? Here + means union. A ((0+1)*1(0+1)*1)*10*; B (0*10*10*)*0*1; C 10*(0*10*10*)*; D (0*10*10*)*10*. The official answer is MTA, not a letter.
Tap to enlarge
Your answer
Answer & solution

Official answer: MTA

Our answer: No correct option; official MTA

Worked explanation

Checking a claimed regular expression needs both inclusions: every generated string must have odd parity, and every odd-parity string must be generated. A violates soundness because the arbitrary (0+1)* portions can introduce extra 1s: use the repeated block 111 and final 1 to generate 1111. B violates completeness on 10, because it ends in a mandatory 1. C violates completeness on 01, because its first symbol is 1. In D, zero repeated blocks give a leading 1; a positive number supplies at least two 1s before the final mandatory one, so 01 is again missing. In the corrected teaching expression 0*(10*10*)*10*, the repeated block contributes pairs of 1s and the final block contributes one; the surrounding zero runs allow arbitrary gaps and ends. This correction is explanatory only and does not replace official MTA scoring.

Derivation and answer

Each offered expression fails. A accepts 1111: choose 111 for one repeated block and the final 1, producing an even number of ones. B always ends in 1 and misses the valid string 10. C begins in 1 and misses 01. D also misses 01: zero repetitions begin with 1, while any positive repetition contributes at least two ones before the final 1. A correct expression is 0*(10*10*)*10*. The official key awards MTA, which is preserved rather than mapped to a letter.

Original paper, page 5 · Answer key