Question
Consider the language given by the regular expression over the alphabet . The smallest number of states needed in a deterministic finite-state automaton (DFA) accepting is ______.
Official answer and solution
- Official answer
- 4
- From
- Official GATE 2017 answer key
Solution
Construct the minimal DFA for strings whose second symbol from the right is 'b'.
The language consists of all strings over whose second character from the right is .
To determine the acceptance of any string, a DFA must track the last two symbols read:
- State : last two symbols end in (or at the start before any is read).
- State : last two symbols end in (second from right is , most recent is ).
- State : last two symbols end in (second from right is , most recent is ) - Accepting state.
- State : last two symbols end in (second from right is , most recent is ) - Accepting state.
Let us verify state transitions:
- From : on ; on .
- From : on ; on .
- From : on ; on .
- From : on ; on .
All 4 states are pairwise distinguishable:
- and are rejecting, whereas and are accepting.
- on leads to (rejects with string ), whereas on leads to (accepts with string ). Hence, .
- on leads to (rejects with string ), whereas on leads to (accepts with string ). Hence, .
Therefore, the minimal DFA requires exactly 4 states.
4.0
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2017 Computer Science and Information Technology (CS) Session 1
- Question
- 22 of 65, printed as CS Q.22
- 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.