Which one of the following regular expressions represents the set of all binary strings with an odd number of 1's?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2020 · Q7
Time
Select one answerSingle correct
Solution
Official answer: D
Regular Expressions and Finite AutomataA binary string with an odd number of 's consists of an odd number of 's separated and surrounded by any number of 's.
Evaluating the visible options:
Option (A): can generate strings with an even number of 's because allows any number of 's within it.
Option (B): requires the string to end with a , failing to generate strings with an odd number of 's that end in (e.g., ).
According to the official answer key, the correct option is (D) (which is located on the next page: or equivalent form).
*(Note: Options C and D are located on the subsequent page; this question continues onto the next page).*
Try the question first, then check your work.
Examiner trap
Look for a regular expression that guarantees an odd count of 's by grouping pairs of 's with an extra , and allows 's to appear anywhere (including at the very end).
This Regular Expressions and Finite Automata previous year question is Q7 of the GATE CSE 2020 paper. Find more GATE CSE PYQs on Regular Expressions and Finite Automata in Theory of Computation, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Regular Expressions and Finite Automata PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Regular Expressions and Finite Automata has 41 GATE CSE PYQs across 24 papers from 2011 to 2026. 14 of them are 1-mark MCQs like this one, and GATE CSE 2020 has 2.
How GATE tests Regular Expressions and Finite AutomataIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.