Skip to content
Official PYQ · 2017

GATE CS 2017 Set 2 Q25 — Regular Expressions and Finite Automata

Explain with AI
The minimum possible number of states of a deterministic finite automaton that accepts the regular language LL = {w1aw2w_{1}aw_{2} | w1,w2w_{1},w_{2} ∈\in {a,b}∗\left \{ a,b \right \}^{*} , ∣w1∣=2,∣w2∣≥3\left | w_{1} \right | = 2, \left | w_{2} \right |\geq 3} is ______________ .
View worked solution

Answer: 8

The given language is L={w1aw2∣w1,w2∈{a,b}∗,∣w1∣=2,∣w2∣≥3}L = \{w_1 a w_2 \mid w_1, w_2 \in \{a,b\}^*, |w_1| = 2, |w_2| \ge 3\}.

We can simplify the conditions for any string s∈Ls \in L as follows:

  1. The total length of the string must be at least 2+1+3=62 + 1 + 3 = 6 (i.e., ∣s∣≥6|s| \ge 6).
  2. The 3rd3^{\text{rd}} symbol of the string must be ′a′'a'.

To construct the minimal DFA, we track the number of symbols read and ensure the 3rd3^{\text{rd}} symbol is ′a′'a':

  • State 0: Start state (0 symbols read).
  • State 1: 1 symbol read.
  • State 2: 2 symbols read.
  • State 3: 3 symbols read, and the 3rd3^{\text{rd}} symbol was ′a′'a'.
  • State 4: 4 symbols read (with 3rd3^{\text{rd}} symbol ′a′'a').
  • State 5: 5 symbols read (with 3rd3^{\text{rd}} symbol ′a′'a').
  • State 6: 6 or more symbols read (with 3rd3^{\text{rd}} symbol ′a′'a'). This is the only accepting state.
  • Dead State (D): Transitioned to if the 3rd3^{\text{rd}} symbol is ′b′'b'.

Since the minimum length of a string required to reach the accepting state from each of these 8 states is unique (6,5,4,3,2,1,0,6, 5, 4, 3, 2, 1, 0, and ∞\infty respectively), no two states can be merged. Thus, the DFA is minimal.

Therefore, the minimum number of states is 8.

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

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