简体   繁体   中英

How to design a DFA assuming that 0 is not an even number?

How to design a DFA that accepts even number of 0 and even number of 1, assuming 0 is not an even number? Input alphabets Σ= (0,1)

The usual way to handle parity checks works to set up a base of 4 states:

--> ((Q0)) <-0-> (Q1)
      ^           ^
      |           |
      1           1
      |           |
      V           V
     (Q2)  <-0-> (Q3)

Q0 is the even-parity state for both 0 and 1. But 0 is even, so this isn't quite what we need.

So let's look at getting to Q0 by reading 0s.

--> (A) --0-> (B) --0-> (C)

Is (C) = (Q0)? No, because we've not yet read an even number of 1s.

--> (A) --0-> (B) --0-> (C) --1-> (D) --1-> ((Q0))

That works but isn't sufficient: we're missing strings like 1100 and 000011. Is (A) = (C)? No, as (A) represents no 0s or 1s, whereas (C) has encountered 2 0s. Let's expand this by considering what happens in each state with the inputs we haven't yet considered. Is (D) = (Q2)? Both represent even 0s and odd 1s, so yes.

  • Where does (C) go on 0? To (B), representing an odd number of 0s and zero 1s.
  • Where does (A) go on 1? Down a similar, but distinct path on its way to ((Q0)).
  • Where does (B) go on 1? To a state representing odd 0s and 1s.

This should be enough to let you find the answer. You'll know you have the right answer if you end up with 9 states.

Here four cases arises First case Even number of 0 and even number of 1 and Second case Even number of 0 and odd number of 1 and Third case Odd number of 0 and even number of 1 and Fourth case Odd number of 0 and odd number of 1.

And in your case Even number of 0 and Even number of 1.在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM