Write regular expresiond and find finite automata

51 Views Asked by At

I am learning about finite automata and regular expressions, but I cannot find solution to a problem, so I'll be thankfull if someone can help me. Thanks in advance.

The problem is:

Write regular expression and find finite automata that have the same number of 1 and 0 and there isn't word prefix that has difference between the number of 1 and the number of 0 bigger than 1.

1

There are 1 best solutions below

3
On

This automaton has the state set $S=\{B,E,+1,+0, F0,F1\}$. The inputs are $0$s or $1$s the outputs are also $0$ or $1$. The automaton is waiting in state $B$ and in state $F0$ it gives the output $0$ signaling that difference between the zeros and the ones coming in is $2$ the first time. In state $F1$ it gives the output $1$ signaling the other meaningful event.

The state transition function is given by the following graph. enter image description here