Design DFA which checks whether a given binary number is divisible by 3


SOLUTION:

∑={0,1}

Decimal No.
Binary No.
Remainder
States representing Remainders
0
0000
0
q0
1
0001
1
q1
2
0010
2
q2
3
0011
0
q0
4
0100
1
q1
5
0101
2
q2
6
0110
0
q0
7
0111
1
q1
8
1000
2
q2


Ø  So DFA can be Q={ q0 , q1 , q2},∑={0,1}, q0={ q0},F={ q0} and δ is given by the table

1)Transition diagram:




   2)Transition Table:

Present State
Next State
Input 0
Input 1
à *q0
q0
q1
    q1
q2
q0
    q2
q1
q2

Since the number should be divisible by 3, so final state will be q0

  3)Transition function:
δ( q0, 0)= q0    ,δ (q0,1)= q1
            δ( q1, 0)= q2    ,δ (q1,1)= q0   
δ( q2, 0)= q1    ,δ (q2,1)= q2

Comments

Post a Comment

Search related post on google