StreakPeaked· Practice

ExamsGATETechnical

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

  1. (0 + 1)*0011(0 + 1)* + (0 + 1)*1100(0 + 1)*
  2. (0 + 1)*(00(0 + 1)*11 + 11(0 + 1)*00)(0 + 1)*
  3. (0 + 1)*00(0 + 1)* + (0 + 1)*11(0 + 1)*
  4. 00(0 + 1)*11 + 11(0 + 1)*00

Correct answer: (0 + 1)*(00(0 + 1)*11 + 11(0 + 1)*00)(0 + 1)*

Solution

The correct option captures the requirement for the presence of both '00' and '11' in any order within the binary strings, allowing for any characters before or after these patterns. This ensures that the strings can contain any combination of 0s and 1s while still meeting the criteria of having two consecutive 0s and two consecutive 1s.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →