Which one of the following regular expressions represents the language: the set of all binary strings having two consecutive 0s and two consecutive 1s?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2016 Set 1 · Q18
Time
Select one answerSingle correct
Solution
Official answer: B) (0 + 1)*(00(0 + 1)*11 + 11(0 + 1)*00)(0 + 1)*
Regular Expressions and Finite AutomataA string contains two consecutive 0s (00) and two consecutive 1s (11) if either:
00 appears before 11, represented by:
11 appears before 00, represented by:
Taking the union of these two forms and factoring out the common prefix and suffix , we get:
Option (A) requires 00 and 11 to be immediately adjacent (0011 or 1100), which fails to match valid strings like 001011.
Option (C) represents strings containing 00 OR 11, not both.
Option (D) requires strings to start with 00 or 11 and end with 11 or 00, missing strings like 100110.
Thus, (B) is the correct option.
Try the question first, then check your work.
Examiner trap
The string must contain both 00 and 11 in any order, possibly separated and surrounded by arbitrary binary sequences.
This Regular Expressions and Finite Automata previous year question is Q18 of the GATE CSE 2016 Set 1 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 it is the only one in GATE CSE 2016 Set 1.
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.