So I am trying to convert this DFA into an Regular Expression. I got an answer but I am not 100% is correct I feel like it is too long. From my understanding, I just need to find the transitions into the accepting state and write them in an expression.
I got
L(1,1,0) = a*
L(1,2,0 = b
L(1,2,1) = a* b
L(2,2,0) = a*
L(2,2,1) = (ba* b)* a loop
so in the end I got
b U (a* b)U(a * b)a U (a * ba * ba * b)*
I feel like this is too long for an answer... is this even correct?
This DFA is simple enough that we can do it ‘by eye’ rather than by an algorithm. It’s clear that we need an odd number of $b$s in order for a word to be accepted: an even number leaves us in state $1$, while an odd number puts us in state $2$. Reading $a$s never changes the state. Thus, any word that’s accepted must end in $ba^*$. Before that it can have any even number of $b$s interspersed arbitrarily with any number of $a$s, and we might as well assume that it ends up in state $1$. That means that it can repeat $a^*ba^*b$ any number of times, so $(a^*ba^*b)^*ba^*$ almost works – ‘almost’ because it misses the words with just one $b$ that begin with $a$. We could add these with a union, but there’s a slicker solution: $a^*(ba^*ba^*)^*ba^*$.
In other words, we can spin our wheels as long as we like in state $1$, then repeat the process
any number of times (including none), and finally go to state $2$ and possibly spin our wheels there for a while.