Question

The number of states in the minimum sized DFA that accepts the language defined by the regular expression

(0+1)∗(0+1)(0+1)∗(0 + 1)^* (0 + 1)(0 + 1)^*

is ________.

Official answer and solution
Official answer
2
From
Official GATE 2016 answer key

Solution

Identify the language denoted by the regular expression and construct the minimal state DFA.

The given regular expression is:

R=(0+1)∗(0+1)(0+1)∗R = (0 + 1)^* (0 + 1)(0 + 1)^*

Here, (0+1)∗(0 + 1)^* generates any binary string of length ≥0\ge 0. The middle term (0+1)(0 + 1) requires at least one symbol (0 or 1) to be present.

Therefore, RR generates the language of all binary strings of length at least 1:

L=Σ+=Σ∗∖{ε}L = \Sigma^+ = \Sigma^* \setminus \{\varepsilon\}

Construct the minimal DFA for L=Σ+L = \Sigma^+ over Σ={0,1}\Sigma = \{0, 1\}:

  1. Start state q0q_0 (non-accepting): represents the empty string ε\varepsilon. On reading 0 or 1, it transitions to q1q_1.
  2. State q1q_1 (accepting): represents any string of length ≥1\ge 1. On reading 0 or 1, it stays in q1q_1 (self-loop).

Both states are reachable and non-equivalent (q0q_0 is non-accepting and q1q_1 is accepting). Hence, the minimum sized DFA has exactly 2 states.

Final answer

2

Common trap

Constructing an NFA with 3 states and not minimizing the resulting DFA.

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

Source

Paper
GATE 2016 Computer Science and Information Technology (CS) Session 2
Question
26 of 65, printed as CS Q.16
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.