GateAI
Regular Expressions and Finite Automata

GATE CSE 2016 Set 1 · Q18

MCQ1 markEasy

Time

Which one of the following regular expressions represents the language: the set of all binary strings having two consecutive 0s and two consecutive 1s?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: B) (0 + 1)*(00(0 + 1)*11 + 11(0 + 1)*00)(0 + 1)*

Regular Expressions and Finite Automata

A string contains two consecutive 0s (00) and two consecutive 1s (11) if either:

  1. 00 appears before 11, represented by: (0+1)∗00(0+1)∗11(0+1)∗(0 + 1)^*00(0 + 1)^*11(0 + 1)^*

  2. 11 appears before 00, represented by: (0+1)∗11(0+1)∗00(0+1)∗(0 + 1)^*11(0 + 1)^*00(0 + 1)^*

Taking the union of these two forms and factoring out the common prefix (0+1)∗(0 + 1)^* and suffix (0+1)∗(0 + 1)^*, we get:

(0+1)∗(00(0+1)∗11+11(0+1)∗00)(0+1)∗(0 + 1)^*(00(0 + 1)^*11 + 11(0 + 1)^*00)(0 + 1)^*
  • 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.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

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

Where do you stand for GATE?

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.

One GATE CSE PYQ every morning

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 in GATE CSE

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 Automata

More from GATE CSE 2016 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2016 Set 1 · Q18 · MCQ

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

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.