If you want a non-deterministic finite automaton, you can use an algorithm that does the conversion based on operations in the regular expression:
+
turns into nondeterministic branching epsilon transitions
- concatenation turns into sequential transitioning from state to state
- Kleene star turns into loops
Your NDA would look something like this:
a b
^ ^
q0--e-->q1--e-->q2
|
e
|
V
q4--e-->q5
v v
b a
If you want a deterministic finite automaton, you can determinize the nonseterministic one using a known algorithm. Otherwise, we can run Myhill-Nerode in reverse to find equivalence classes under the indistinguishability relation; this will give us the states of a minimal DFA.
- e can be followed by any string in
L
, and is in our language; this class is [e] and corresponds to initial state q0 which is accepting
- a can be followed only by ab; a is in the language, so class [a] corresponds to accepting state q1
- b can be followed only by ba; b is in the language, so class [b] corresponds to accepting state q2
- ab can be followed only by b*; [ab], q, accepting
- ba can be followed only by a*; [ba], q4, accepting
- aba, bab not in language and can never be fixed; [aba], q5, not accepting
- all other strings of length 3 are indistinguishable from strings already seen; we're done
So there's a DFA with 6 states - 1 initial (q0), 5 accepting and 1 dead (q5) - which accepts the language. You can figure out the transitions as follows: each state is arrived at after following any string which belongs to its equivalence class. Note that the dead state q5 must have two self-loops as its transitions.