Skip to content
Official PYQ · 1998

GATE CS 1998 Q2.5 — Regular Expressions and Finite Automata

Explain with AI

Let LL be the set of all binary strings whose last two symbols are the same. The number of states in the minimal state deterministic finite state automaton accepting LL is 

Choose one option
View worked solution

Answer: B

The language LL consists of all binary strings over the alphabet Σ={0,1}\Sigma = \{0, 1\} that end with either 0000 or 1111. That is:

L={w∈{0,1}∗∣w ends with 00 or 11}L = \{ w \in \{0, 1\}^* \mid w \text{ ends with } 00 \text{ or } 11 \}

Let us construct the Deterministic Finite Automaton (DFA) for LL by tracking the suffix of the input string processed so far. We define the following 5 states:

  • q0q_0: Start state (empty string ϵ\epsilon processed).
  • q1q_1: The string processed so far ends in 00 (but not 0000).
  • q2q_2: The string processed so far ends in 11 (but not 1111).
  • q3q_3: The string processed so far ends in 0000 (Accepting state).
  • q4q_4: The string processed so far ends in 1111 (Accepting state).

The transition rules for these states are as follows:

State On input 00 On input 11
→q0\rightarrow q_0 q1q_1 q2q_2
q1q_1 q3q_3 (Accept) q2q_2
q2q_2 q1q_1 q4q_4 (Accept)
∗q3*q_3 q3q_3 (Accept) q2q_2
∗q4*q_4 q1q_1 q4q_4 (Accept)

To verify if this DFA is minimal, we check for equivalent states:

  1. The accepting states {q3,q4}\{q_3, q_4\} cannot be merged because on input 00, q3q_3 stays in an accepting state (q3q_3) while q4q_4 goes to a non-accepting state (q1q_1).
  2. The non-accepting states {q0,q1,q2}\{q_0, q_1, q_2\} cannot be merged because:
    • On input 00, q1q_1 transitions to an accepting state (q3q_3) while q0q_0 and q2q_2 transition to non-accepting states.
    • On input 11, q2q_2 transitions to an accepting state (q4q_4) while q0q_0 transitions to a non-accepting state.

Since no two states are equivalent, all 55 states are pairwise distinguishable. Thus, the minimal DFA has exactly 55 states.

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

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