Here we get final state by one or several time of ‘a b’ OR (+) by one or several time of ‘b a’ OR (+) combination of ‘ab’ and ‘ba’.
By taking longest path regular expression RE = (ab + ba)*
Here regular expression is simple because we get initial state to final state only by input a. And another state is trap state.
Regular Expression RE = a