Which one of the following regular expressions correctly represents the…

2022

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

  1. A.

    ab* bab* + ba* aba*

  2. B.

    (ab*b)* ab* - (ba*a)* ba*

  3. C.

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

  4. D.

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

Attempted by 139 students.

Show answer & explanation

Correct answer: D

Key idea: decompose any accepted string into a sequence of small building blocks that mirror moves between the start and the two accepting states.

  • Final segment: any accepted string must end by moving from the start to one of the accepting states and then taking zero or more loop symbols there. Those two possibilities are ab* (start → top accepting, then any number of b's) and ba* (start → bottom accepting, then any number of a's). So the final part is (ab* + ba*).

  • Round trips: each time the automaton leaves and then returns to the same phase it consumes a block of the form ba*a (go from bottom-side into top-side and back) or ab*b (go from top-side into bottom-side and back). These two block types are combined as (ba*a + ab*b).

  • Putting it together: you may repeat those round trips zero or more times and then finish with the final segment. That yields the regular expression (ba*a + ab*b)*(ab* + ba*).

Therefore the correct regular expression for the language of the given automaton is (ba*a + ab*b)*(ab* + ba*).

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir