Question

Which of the regular expressions given below represent the following DFA?

Deterministic finite automaton with two states accepting binary strings

I) 0∗1(1+00∗1)∗0^* 1(1 + 00^* 1)^*
II) 0∗1∗1+11∗0∗10^* 1^* 1 + 11^* 0^* 1
III) (0+1)∗1(0 + 1)^* 1

Choose one option
Official answer and solution
Official answer
B
From
Official GATE 2014 answer key

Solution

Determine the language accepted by the DFA by analyzing state transitions and compare against the candidate regular expressions.

The DFA has two states q0q_0 (start state) and q1q_1 (accepting state):

  • From q0q_0: on 0 remains at q0q_0; on 1 transitions to q1q_1.
  • From q1q_1: on 0 transitions to q0q_0; on 1 remains at q1q_1.

Notice that:

  • Any transition on 1 leads to or stays in the accepting state q1q_1.
  • Any transition on 0 leads to or stays in the non-accepting state q0q_0.
    Therefore, the DFA accepts precisely all strings over {0,1}\{0, 1\} that end with '1'.

Now test each regular expression:

  • (I) 0∗1(1+00∗1)∗0^* 1(1 + 00^* 1)^*:
    Begins with 0∗10^* 1 (first occurrence of 1), followed by any number of blocks that each end with 1 (11 or 00∗100^* 1). Every string generated ends with 1, and any string ending with 1 can be decomposed into such blocks. Thus I represents the DFA.

  • (II) 0∗1∗1+11∗0∗10^* 1^* 1 + 1 1^* 0^* 1:
    The first term generates strings of the form 0m1n0^m 1^n (n≥1n \ge 1).
    The second term generates strings of the form 1m0n11^m 0^n 1 (m≥1m \ge 1).
    Consider the string 01010101, which ends with 1 and is accepted by the DFA. It cannot be generated by 0∗1∗10^* 1^* 1 (has an alternating 0 after 1) nor by 11∗0∗111^* 0^* 1 (starts with 0). Thus II does not represent the DFA.

  • (III) (0+1)∗1(0 + 1)^* 1:
    This is the canonical regular expression for all strings ending with 1. Thus III represents the DFA.

Therefore, I and III only represent the DFA (Option B).

Final answer

B

Common trap

Assuming regular expression II can generate all strings ending in 1, missing counterexamples with multiple alternations like 0101.

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

Source

Paper
GATE 2014 Computer Science and Information Technology (CS) Session 1
Question
46 of 65, printed as CS Q.36
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.