Skip to content
Official PYQ · 2022

GATE CS 2022 Q2 — Regular Expressions and Finite Automata

Explain with AI

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

Choose one option
View worked solution

Answer: D

To find the regular expression for the given finite automaton, we analyze the paths starting from the initial state q0q_0 to the final states q1q_1 and q2q_2:

  1. Loops returning to q0q_0: From the start state q0q_0, we can loop back to q0q_0 in two ways:
    • By going to q1q_1 via aa, looping on q1q_1 with b∗b^*, and returning to q0q_0 via bb. This path is represented by ab∗bab^*b.
    • By going to q2q_2 via bb, looping on q2q_2 with a∗a^*, and returning to q0q_0 via aa. This path is represented by ba∗aba^*a.
    Any number of these loops can be combined in any order, which is represented by:(ba∗a+ab∗b)∗(ba^*a + ab^*b)^*
  2. Reaching the final states: From q0q_0, the final transition to an accepting state must be:
    • To the final state q1q_1 via aa followed by any number of bb's: ab∗ab^*
    • To the final state q2q_2 via bb followed by any number of aa's: ba∗ba^*
    This gives the final part of the expression: (ab∗+ba∗)(ab^* + ba^*).

Combining these two parts, the complete regular expression is:

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

Thus, the correct option is D.

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

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