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
GATE CSE 2017 Set 2 · Q25
Time
Your answerNumerical answer
Solution
Official answer: 8 (±0)
Regular Expressions and Finite AutomataThe given language requires strings that:
Have , so the character must be specifically 'a'.
Have , so the total length of the string must be at least .
Let us construct the minimal DFA states tracking the relevant prefix length and matching condition:
: Start state (length )
: Length
: Length
From :
On input 'a', transition to (length , symbol is 'a').
On input 'b', transition to a dead/trap state (length , symbol is not 'a', string can never be accepted).
: Length , valid symbol
: Length
: Length
: Length (Final/accepting state, with self-loops on )
: Dead state (with self-loops on )
Counting all states:
Total number of states = 8.
Try the question first, then check your work.
Examiner trap
Consider the exact length requirements and note that strings having 'b' at the 3rd position must lead to a non-accepting trap state.
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
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.
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 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 AutomataIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.