Question
Official answer and solution
- Official answer
- C
- From
- Official GATE 2025 answer key
Solution
Label the four states from left to right as and track the longest suffix of the input read so far that matches a prefix of .
Label the states from left to right as (start), , , and (accept):
- : Longest suffix matching a prefix of
babis (on , on ). - : Longest matching suffix is
b(on , on ). - : Longest matching suffix is
ba(on sincebaahas no non-empty prefix ofbabas suffix; on ). - (accepting): Longest matching suffix is
bab(on sincebabaends withba; on sincebabbends withb).
Because the DFA leaves the accepting state whenever the string no longer ends with bab, it accepts precisely the set of all strings ending with the pattern .
Option (C)
Selecting (B), which would require the accepting state to have a self-loop on both and .
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.