Dfa for a language {0,1} that has even length or it ends with a 0.

351 Views Asked by At

Accepted strings would be {"", 11, 100, 1010, 1111} And it would reject everything that is not even length or it ends with a 0.

I constructed two dfa, one that accepts all possible even combinations, and one that ends with a 0, but I can't combine them.

After a bit of thinking, I kinda believe that three states must be enough, but still can't make it work.

Any help is greatly appreciated. enter image description here

1

There are 1 best solutions below

5
On BEST ANSWER

I originally misread the question, this should be the corrected answer:

State 1 is initial, states 1 and 2 are terminal (i.e. accepting).

enter image description here

There are three relevantly distinct possibilites at each step:

  1. The current number of characters is even; accepting.
  2. The current number of characters is odd, but the last character was zero; accepting.
  3. The current number of characters is odd and the last character was a one; rejecting.