GateAI
Regular Expressions and Finite Automata

GATE CSE 2025 Set 1 · Q50

MSQ2 marksMedium

Time

Consider the following deterministic finite automaton (DFA) defined over the alphabet, Σ={a,b}\Sigma = \{a, b\}. Identify which of the following language(s) is/are accepted by the given DFA.

GATE CSE 2025 Set 1 Q50 diagram

Select all that applyOne or more correct

Pick every correct option

Solution

Step-by-step verified solution

Official answer: C) The set of all strings ending with the pattern bab.

Regular Expressions and Finite Automata

Let the four states from left to right be denoted as q0q_0 (start state), q1q_1, q2q_2, and q3q_3 (accepting state).

Let us trace the meaning of each state based on the longest suffix of the input processed so far:

  • q0q_0: Represents strings ending with an aa (not part of the suffix baba), or the empty string ϵ\epsilon.

    • On input aa, stays at q0q_0.

    • On input bb, transitions to q1q_1.

  • q1q_1: Represents strings whose longest relevant suffix is bb.

    • On input bb, stays at q1q_1.

    • On input aa, transitions to q2q_2 (suffix is now baba).

  • q2q_2: Represents strings whose longest relevant suffix is baba.

    • On input bb, transitions to q3q_3 (suffix is now babbab).

    • On input aa, transitions back to q0q_0 (suffix becomes baabaa, resetting pattern tracking to aa).

  • q3q_3 (Accepting state): Represents strings whose longest relevant suffix is babbab.

    • On input aa, suffix becomes babababa, whose longest suffix matching a prefix of babbab is baba, so it transitions back to q2q_2.

    • On input bb, suffix becomes babbbabb, whose longest suffix matching a prefix of babbab is bb, so it transitions back to q1q_1.

Since q3q_3 is the only accepting state, a string is accepted if and only if the automaton ends in state q3q_3 after processing the entire string. This occurs precisely when the string ends with the substring babbab.

Therefore, the DFA accepts the set of all strings ending with the pattern babbab (Option C).

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

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

More from GATE CSE 2025 Set 1

Share this solution

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

GateAI solution cardGATE CSE 2025 Set 1 · Q50 · MSQ

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

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