Question

The minimum possible number of states of a deterministic finite automaton that accepts the regular language 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\} is

Official answer and solution
Official answer
8
From
Official GATE 2017 answer key

Solution

Construct the minimal deterministic finite automaton (DFA) recognizing the length-constrained language LL.

The 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\}.
This requires:

  1. Exactly 2 arbitrary characters of w1w_1 (positions 1 and 2).
  2. The 3rd character must be 'aa'.
  3. Followed by at least 3 arbitrary characters of w2w_2 (positions 4, 5, 6 and beyond).

Construct the DFA states based on progress through the required string structure:

  • State q0q_0: Start state (0 symbols read).
  • State q1q_1: 1st symbol read from {a,b}\{a, b\}.
  • State q2q_2: 2nd symbol read from {a,b}\{a, b\}.
  • From q2q_2:
    • On 'aa': Successfully reads the mandatory 'aa' at position 3; transitions to q3q_3.
    • On 'bb': The 3rd symbol is 'bb', which violates the definition since ∣w1∣|w_1| must be exactly 2; transitions to dead/trap state qtrapq_{\text{trap}}.
  • State q3q_3: 3 symbols read (including 'aa' at position 3). Needs at least 3 symbols to accept.
  • State q4q_4: 4 symbols read (1 symbol of w2w_2).
  • State q5q_5: 5 symbols read (2 symbols of w2w_2).
  • State q6q_6: 6 or more symbols read (at least 3 symbols of w2w_2). This is the accepting state; self-loops on {a,b}\{a, b\}.
  • State qtrapq_{\text{trap}}: Dead state; self-loops on {a,b}\{a, b\}.

Total number of states in this minimal DFA is:

{q0,q1,q2,q3,q4,q5,q6,qtrap}=8 states\{q_0, q_1, q_2, q_3, q_4, q_5, q_6, q_{\text{trap}}\} = 8 \text{ states}
Final answer

8

Common trap

Forgetting the dead/trap state for inputs whose 3rd symbol is 'bb'.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2017 Computer Science and Information Technology (CS) Session 2
Question
25 of 65, printed as CS Q.25
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.