GateAI
Regular Expressions and Finite Automata

GATE CSE 2017 Set 2 · Q25

NAT1 markMedium

Time

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 ________.

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 8 (±0)

Regular Expressions and Finite Automata

The given language requires strings that:

  1. Have ∣w1∣=2|w_1| = 2, so the 3rd3^{\text{rd}} character must be specifically 'a'.

  2. Have ∣w2∣≥3|w_2| \ge 3, so the total length of the string must be at least 2+1+3=62 + 1 + 3 = 6.

Let us construct the minimal DFA states tracking the relevant prefix length and matching condition:

  • q0q_0: Start state (length 00)

  • q1q_1: Length 11

  • q2q_2: Length 22

  • From q2q_2:

    • On input 'a', transition to q3q_3 (length 33, 3rd3^{\text{rd}} symbol is 'a').

    • On input 'b', transition to a dead/trap state qtrapq_{\text{trap}} (length 33, 3rd3^{\text{rd}} symbol is not 'a', string can never be accepted).

  • q3q_3: Length 33, valid 3rd3^{\text{rd}} symbol

  • q4q_4: Length 44

  • q5q_5: Length 55

  • q6q_6: Length ≥6\ge 6 (Final/accepting state, with self-loops on a,ba, b)

  • qtrapq_{\text{trap}}: Dead state (with self-loops on a,ba, b)

Counting all states:

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

Total number of states = 8.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Regular Expressions and Finite Automata previous year question is Q25 of the GATE CSE 2017 Set 2 paper. Find more GATE CSE PYQs on Regular Expressions and Finite Automata in Theory of Computation, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Regular Expressions and Finite Automata PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Regular Expressions and Finite Automata in GATE CSE

Regular Expressions and Finite Automata has 41 GATE CSE PYQs across 24 papers from 2011 to 2026. 5 of them are 1-mark NAT questions like this one, and GATE CSE 2017 Set 2 has 2.

How GATE tests Regular Expressions and Finite Automata

More from GATE CSE 2017 Set 2

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2017 Set 2 · Q25 · NAT

The minimum possible number of states of a deterministic finite automaton that accepts the regular language L = {w1 a w2 w1, w2 ∈ {a, b}*, |w1| = 2, |w2| ≥ 3} is …

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.