Consider the following deterministic finite automaton (DFA) defined over the alphabet, = {a, b}. Identify which of the following language(s) is/are accepted by the given DFA.
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2025 Set 1 · Q50
Time

Select all that applyOne or more correct
Solution
Official answer: C) The set of all strings ending with the pattern bab.
Regular Expressions and Finite AutomataLet the four states from left to right be denoted as (start state), , , and (accepting state).
Let us trace the meaning of each state based on the longest suffix of the input processed so far:
: Represents strings ending with an (not part of the suffix ), or the empty string .
On input , stays at .
On input , transitions to .
: Represents strings whose longest relevant suffix is .
On input , stays at .
On input , transitions to (suffix is now ).
: Represents strings whose longest relevant suffix is .
On input , transitions to (suffix is now ).
On input , transitions back to (suffix becomes , resetting pattern tracking to ).
(Accepting state): Represents strings whose longest relevant suffix is .
On input , suffix becomes , whose longest suffix matching a prefix of is , so it transitions back to .
On input , suffix becomes , whose longest suffix matching a prefix of is , so it transitions back to .
Since is the only accepting state, a string is accepted if and only if the automaton ends in state after processing the entire string. This occurs precisely when the string ends with the substring .
Therefore, the DFA accepts the set of all strings ending with the pattern (Option C).
Try the question first, then check your work.
Examiner trap
Track what suffix of the input string each state corresponds to, especially the single accepting state.
This Regular Expressions and Finite Automata previous year question is Q50 of the GATE CSE 2025 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. 4 of them are 2-mark MSQs like this one, and GATE CSE 2025 Set 1 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.