Skip to content
Official PYQ · 2023

GATE CS 2023 Q53 — Regular Expressions and Finite Automata

Explain with AI
Consider the language LL over the alphabet {0,1}\{0,1\}, given below:
L={w∈{0,1}∗∣w does not contain three or more consecutive 1 ’s }.L=\left\{w \in\{0,1\}^{*} \mid w \text{ does not contain three or more consecutive } 1 \text{ 's }\right\} .
The minimum number of states in a Deterministic Finite-State Automaton (DFA)\text{(DFA)} for LL is ____________.
View worked solution

Answer: 4

The language LL consists of all strings over {0,1}\{0,1\} that do not contain the substring 111111. We can construct the minimal DFA by tracking the number of consecutive 11s seen at the end of the input string.

Let the states represent the following tracking information:

  • q0q_0 (Start, Accepting): No consecutive 11s at the end (the last character read was 00, or the string is empty).
  • q1q_1 (Accepting): Exactly one consecutive 11 at the end.
  • q2q_2 (Accepting): Exactly two consecutive 11s at the end.
  • q3q_3 (Non-accepting, Trap): Three or more consecutive 11s have been seen (the substring 111111 has occurred).

The transitions are defined as follows:

  • From q0q_0: on 0→q00 \to q_0, on 1→q11 \to q_1
  • From q1q_1: on 0→q00 \to q_0, on 1→q21 \to q_2
  • From q2q_2: on 0→q00 \to q_0, on 1→q31 \to q_3
  • From q3q_3: on 0,1→q30, 1 \to q_3

To verify minimality, we check if any states can be merged:

  • q3q_3 is non-accepting, while q0,q1,q2q_0, q_1, q_2 are accepting, so q3q_3 cannot be merged with any other state.
  • From q2q_2, input 11 leads to q3q_3 (non-accepting), whereas from q0q_0 and q1q_1, input 11 leads to accepting states. Thus, q2q_2 is distinguishable.
  • From q1q_1, input 1111 leads to q3q_3 (non-accepting), whereas from q0q_0, input 1111 leads to q2q_2 (accepting). Thus, q1q_1 and q0q_0 are distinguishable.

Since all 4 states are pairwise distinguishable, the minimum number of states in the DFA is 4.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Regular Expressions and Finite Automata questions