Skip to content
Official PYQ · 2017

GATE CS 2017 Set 1 Q22 — Regular Expressions and Finite Automata

Explain with AI
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 ___________ .
View worked solution

Answer: 4

The given regular expression is L=(a+b)∗b(a+b)L = (a+b)^{*} b (a+b) over the alphabet {a,b}\{a,b\}. This language consists of all strings where the second symbol from the right end is bb.

In general, a deterministic finite automaton (DFA) that recognizes the language of strings where the kk-th symbol from the right is a specific character requires at least 2k2^k states. Here, k=2k = 2, so the minimum number of states is 22=42^2 = 4.

We can construct the minimal DFA with the following 4 states representing the history of the last two symbols read:

  • q0q_0 (Start state): Represents having read nothing, or ending in aaaa.
  • q1q_1: Represents ending in abab.
  • q2q_2 (Accepting state): Represents ending in baba.
  • q3q_3 (Accepting state): Represents ending in bbbb.

Since all 4 states are pairwise distinguishable, the minimal DFA has exactly 4 states.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Regular Expressions and Finite Automata questions