Question

Consider the language LL given by the regular expression (a+b)∗b(a+b)(a+b)^* b (a+b) over the alphabet {a,b}\{a, b\}. The smallest number of states needed in a deterministic finite-state automaton (DFA) accepting LL 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 L=(a+b)∗b(a+b)L = (a + b)^* b (a + b) consists of all strings over {a,b}\{a, b\} whose second character from the right is bb.

To determine the acceptance of any string, a DFA must track the last two symbols read:

  • State q00q_{00}: last two symbols end in aaaa (or at the start before any bb is read).
  • State q01q_{01}: last two symbols end in abab (second from right is aa, most recent is bb).
  • State q10q_{10}: last two symbols end in baba (second from right is bb, most recent is aa) - Accepting state.
  • State q11q_{11}: last two symbols end in bbbb (second from right is bb, most recent is bb) - Accepting state.

Let us verify state transitions:

  • From q00q_{00}: on a→q00a \to q_{00}; on b→q01b \to q_{01}.
  • From q01q_{01}: on a→q10a \to q_{10}; on b→q11b \to q_{11}.
  • From q10q_{10}: on a→q00a \to q_{00}; on b→q01b \to q_{01}.
  • From q11q_{11}: on a→q10a \to q_{10}; on b→q11b \to q_{11}.

All 4 states are pairwise distinguishable:

  • q00q_{00} and q01q_{01} are rejecting, whereas q10q_{10} and q11q_{11} are accepting.
  • q00q_{00} on aa leads to q00q_{00} (rejects with string ϵ\epsilon), whereas q01q_{01} on aa leads to q10q_{10} (accepts with string aa). Hence, q00≢q01q_{00} \not\equiv q_{01}.
  • q10q_{10} on bb leads to q01q_{01} (rejects with string ϵ\epsilon), whereas q11q_{11} on bb leads to q11q_{11} (accepts with string bb). Hence, q10≢q11q_{10} \not\equiv q_{11}.

Therefore, the minimal DFA requires exactly 4 states.

Final answer

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.