Question

Which one of the following regular expressions correctly represents the language of the finite automaton given below?

Finite automaton with start state q0 and two accepting states q1 (top) and q2 (bottom). Transitions: q0 to q1 on a, q1 to q0 on b, q1 self-loop on b; q0 to q2 on b, q2 to q0 on a, q2 self-loop on a.
Choose one option
Official answer and solution
Official answer
D
From
Official GATE 2022 answer key

Solution

Decompose paths in the finite automaton into loops from the initial state q0q_0 and transitions to accepting states.

The automaton has start state q0q_0 and two accepting states q1q_1 and q2q_2.

From state q0q_0:

  • Moving to q1q_1 on 'a', looping on 'b' (b∗b^*), and returning to q0q_0 on 'b' corresponds to the sub-expression ab∗ba b^* b.
  • Moving to q2q_2 on 'b', looping on 'a' (a∗a^*), and returning to q0q_0 on 'a' corresponds to the sub-expression ba∗ab a^* a.

Any number of round trips that start and end at q0q_0 can be represented by (ba∗a+ab∗b)∗(ba^*a + ab^*b)^*.

From q0q_0, the path can terminate in an accepting state:

  • Reaching and accepting in q1q_1 via 'a' followed by zero or more 'b's: ab∗a b^*.
  • Reaching and accepting in q2q_2 via 'b' followed by zero or more 'a's: ba∗b a^*.

Combining the cycles at q0q_0 with the terminal paths to the accepting states gives:

(ba∗a+ab∗b)∗(ab∗+ba∗)(ba^*a + ab^*b)^*(ab^* + ba^*)

This matches Option (D).

Final answer

Option (D)

Common trap

Forgetting that loops at q0q_0 can alternate arbitrarily between the q1q_1 branch and the q2q_2 branch.

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

Source

Paper
GATE 2022 Computer Science and Information Technology (CS)
Question
12 of 65
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.