Consider the language L given by the regular expression (a+b)*b(a+b) over the alphabet {a,b} . The smallest number of states needed in a deterministic finite-state automaton (DFA) accepting L is …
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2017 Set 1 · Q22
Time
Your answerNumerical answer
Solution
Official answer: 4 (±0)
Regular Expressions and Finite AutomataThe given regular expression is $L = (a+b)^*b(a+b)$, which describes the set of all strings over $\{a, b\}$ whosesecond symbol from the right is .
In general, for an alphabet of size 2, a DFA that checks whether the -th symbol from the right is a specific symbol requires states, because it must remember the last symbols seen.
Here , so the minimum number of states is:
The 4 states corresponding to the suffix of the last 2 symbols processed are:
: Initial state (suffix or ends with )
: Suffix ends with (specifically preceded by something not enabling acceptance, i.e., seen or )
: Suffix ends with (second symbol from right is not yet )
: Suffix is or (accepting states where the second symbol from right is )
Explicitly, the state set or the standard Myhill-Nerode equivalence classes give exactly 4 states.
Try the question first, then check your work.
Examiner trap
The language contains all strings where the second symbol from the right is . A DFA must keep track of the last two symbols read.
This Regular Expressions and Finite Automata previous year question is Q22 of the GATE CSE 2017 Set 1 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 it is the only one in GATE CSE 2017 Set 1.
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.