Question

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.

A 4-state DFA over {a, b} with unlabeled states from left to right (say q0, q1, q2, q3) where q0 is the start state and q3 is the single accepting state. Transitions: q0 has a self-loop on a and goes to q1 on b; q1 has a self-loop on b and goes to q2 on a; q2 goes to q0 on a and to q3 on b; q3 goes to q2 on a and to q1 on b.
Choose every correct option
Official answer and solution
Official answer
C
From
Official GATE 2025 answer key

Solution

Label the four states from left to right as q0,q1,q2,q3q_0, q_1, q_2, q_3 and track the longest suffix of the input read so far that matches a prefix of babbab.

Label the states from left to right as q0q_0 (start), q1q_1, q2q_2, and q3q_3 (accept):

  • q0q_0: Longest suffix matching a prefix of bab is ϵ\epsilon (on a→q0a \to q_0, on b→q1b \to q_1).
  • q1q_1: Longest matching suffix is b (on b→q1b \to q_1, on a→q2a \to q_2).
  • q2q_2: Longest matching suffix is ba (on a→q0a \to q_0 since baa has no non-empty prefix of bab as suffix; on b→q3b \to q_3).
  • q3q_3 (accepting): Longest matching suffix is bab (on a→q2a \to q_2 since baba ends with ba; on b→q1b \to q_1 since babb ends with b).

Because the DFA leaves the accepting state q3q_3 whenever the string no longer ends with bab, it accepts precisely the set of all strings ending with the pattern babbab.

Final answer

Option (C)

Common trap

Selecting (B), which would require the accepting state q3q_3 to have a self-loop on both aa and bb.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2025 Computer Science and Information Technology - Session 1 (CS1)
Question
50 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.