Design a DFA to check whether the Given Number is Even

14.3k Views Asked by At

I have the following question

enter image description here

I have designed the following

enter image description here

A Binary String is even if it is ending with 0 and odd if its ending with 1.I have applied this.Im i right ?

UPDATE:

enter image description here

1

There are 1 best solutions below

1
On BEST ANSWER

Your answer is incorrect. It rejects strings that are even and therefore should be accepted, like $1100$, and accepts strings that are odd and therefore should be rejected, like $1$.

The correct automaton needs to remember whether the last character read was $1$ or $0$, so we need two states: the initial state and an accepting state. When a $0$ is read, transfer to the accepting state or remain there if we were in the accepting state already. When a $1$ is read, transfer to the initial state or remain there if we were in the initial state already.

When the entire string has been read, if the last character was $0$, we'll be in the accepting state and we'll accept the string as even. If the last character was $1$, we'll be in the initial state and reject the string as odd.

UPDATE: apart from the missing initial state annotation, it looks correct after your update. Well done!