Deterministic finite automata that accepts words with even number of zeros OR even number of ones

92 Views Asked by At

Dear Math Stack Exchange users!

I want to create a deterministic finite automata with max. 5 states, that accepts the language :

$$A:=\{u\in\{0,1\}^*\mid |u|_0\textrm{ mod } 2 \equiv 0\lor|u|_1\textrm{ mod } 2\equiv 0\}.$$

So words over $\{0,1\}$, that have either an even amount of zeros or an even amount of ones or both.

I have seen similar ones where the automata accept words with an even amount of zeros AND an even amount of ones, but never with OR.

I tried a lot of stuff, but I still don't really have a nice approach to this. It seems like it's very complex since I am new to this topic. I feel like the fact that the ones and zeros does not have to be ordered (first all the ones and then zeros or first all the zeros and then the ones) makes it very difficult.

Maybe you guys have an idea and can give me a hint for this. Thank you very much. Kind regards, Max.

1

There are 1 best solutions below

6
On BEST ANSWER

Here is the Starting Point which you can try to Complete (let me know in Case you have Difficulties , I will try to Complete it) :

01

Starting State is "01" where both "0" & "1" are good for us.
When "1" is encountered , we get to State "0" where "0" is still good for us. When "0" is encountered , we get to State "1" where "1" is still good for us.

The left State is "X" where neither "0" nor "1" is good for us.

You can try to put in the other transitions.

Here is the Compete Diagram , which has the 4 States according to your Question :

01

Every State except "X" is good for us.