You are on page 1of 3

MIT International Journal of Computer Science and Information Technology, Vol. 6, No. 1, January 2016, pp.

24-26
ISSN 2230-7621MIT Publications

24

An Efficient Approach to Design


Minimized DFA for Binary Numbers Divisible
by N Where N is in Power of 2
Praveen Saini

Puneet Kumar

Assistant Professor, CS&E Department


MIT, Moradabad, U.P., India
E-mail: praveensaini5@gmail.com

Assistant Professor, CS&E Department


MIT, Moradabad, U.P., India
E-mail: puneetkchahal@gmail.com

Manoj Kumar Singh

Anurag Panday

Assistant Professor, CS&E Department


MIT, Moradabad, U.P., India
E-mail: manojaswal1982@gmail.com

Assistant Professor, CS&E Department


MIT, Moradabad, U.P., India
E-mail: anuragpanday31@gmail.com

ABSTRACT
In this paper we have given a New Approach to design a minimal DFA for the problem Binary Number divisible by N, where
N is in power of 2 without following the Tradition Method of designing and Minimization for Mod N problems over {0,1}.
Keywords: Deterministic Finite Automata, DFA, Minimization, Equivalence Classes, Binary Number/string.

I. Introduction
A DFA [1] [2] is 5-tuple Machine (Q, , , q0, F)
Where
Q, is set of finite states.
, is set of finite symbols.
, transition from one state to another, Q Q.
q0 Q, is the start state.
F Q, is set of final states.

0, is the final state in case of divisible by N problem, otherwise


for residue Mod N, respective remainder will represent final state.
The paper is organized as follows. Sample problem to explain
the approach is given in Section II. Traditional method to design
minimized DFA for sample problem is explained in Section III.
The proposed new method to design minimized DFA is presented
in Section IV. Finally, the conclusions of the paper are presented
in Section V.

II. Sample Problem

As it is universally accepted that Any Number get divided by N,


it gives 0,1,2,3,4,..N1 remainders [1], and Each remainder
denotes an Equivalence Class and result in N states corresponding
to each remainder.

For our Purpose, We are taking a sample problem Design a DFA


for binary numbers divisible by 4 [1].

For divide by N problem

Problem: Design a DFA for binary numbers divisible by 4.

Q = {0, 1, 2 N1}

= {0, 1}

Here, N = 4, so states will be 0, 1, 2 and 3 as they are remainders


coming on dividing any number by 4 [1].

III. Traditional Method

, transition is as

So,

[2 old state + symbol] mod N New state.

Q = {0, 1, 2, 3}

0, state representing remainder 0, is the start state

Input string is binary string

MIT International Journal of Computer Science and Information Technology, Vol. 6, No. 1, January 2016, pp. 24-26
ISSN 2230-7621MIT Publications

so,

25

carefully look on above DFA or Equivalence Class partitioning


Method [3] over the above DFA or on the transition table, we
get something like:

= {0, 1}

0, is the start state.

Firstly we have two classes (i) set of final states and (ii) set of
non-final states

0, is the final state.


Transitions, , are as follows:

p0 = {0}, {1, 2, 3}

[2 0 + 0] mod4 = 0

[2 0 + 1] mod4 = 1

Table 2: Equivalence relation of state 1 and 3

[2 1 + 0] mod4 = 2

[2 1 + 1] mod4 = 3

[2 2 + 0] mod4 = 0

Q\
1
3

[2 2 + 1] mod4 = 1

States 1 and 3 are equivalents

[2 3 + 0] mod4 = 2

[2 3 + 1] mod4 = 3

So,

p1 = {0}, {2}, {1, 3}

and

p2 = p1

The transition table for stated problem is shown in Table 1.


Table 1: Transition Table for stated problem
Q\
0*
1
2
3

0
0
2
0
2

1
1
3
1
3

Where, denotes start state, * denotes final state.


DFA M is shown in Fig. 1

0
2
2

1
3
3

So it cannot be further minimized [1].


Transition table for Minimized DFA is shown in Table 3.
Table 3: Minimized Transition table
Q\
0*
1,3
2

0
0
2
0

1
1,3
1,3
1,3

Minimized DFA M shown in Fig. 3 have only 3 states.

Fig. 2. DFA M

IV. Proposed Approach


Problem: Design a DFA for binary numbers divisible by 4.
Fig. 1. DFA M

We can say we get the DFA for binary numbers divide by 4 having
4 states, 0, 1, 2, and 3, representing distinct remainder. But if we

If, N can be written as 2n, then we need to design DFA for binary
strings ending with n 0s, having n + 1 states.
Here N = 4
4 can be written in power of 2 as 22.

MIT International Journal of Computer Science and Information Technology, Vol. 6, No. 1, January 2016, pp. 24-26
ISSN 2230-7621MIT Publications

26

As per New Approach, if N can be written as 2n, then we need


to design DFA for binary strings ending with n 0s.
So, we need to design DFA for binary strings ending with 00,
having regular expression (0+1) 00.
DFA M is shown in Fig. 3.

Fig. 4: DFA M

The minimized DFA M designed by using new proposed


method is exactly same as minimized DFA M designed by
traditional method. But the steps required by new approach are
less than traditional approach. This shows that new approach is
more efficient than traditional approach.

V. ConClusion
In this paper we have seen that we can draw a minimized DFA for
binary number divisible by N, where N= 2n by simply drawing
DFA ending with n 0s and making final state as initial too, with
easier way and without minimization and in lesser steps.
Fig. 3. DFA M

DFA M is similar to minimized DFA M designed using


Traditional Approach, expect one string that accept in M, but
not in M, that is, epsilon.
Even that epsilon doesnt contain any binary symbol if we include
epsilon in DFA M, with the slightly change by make q2 as start
state instead of q0.
Final minimized DFA M is shown in Fig. M.

In one word, we can give the number of state in Minimal DFA,


that is, n+1.

References
[1] Peter Linz, An Introduction to Formal Languages and Automata,
Jones & Bartlett, 2011.
[2] Hopcroft, J & Ullman, J., Introduction to Automata Theory,
Languages, and Computation, Addison-Wilsey, 2008.
[3] http://www.comp.nus.edu.sg/~sanjay/cs4232/dfa-min.pdf

You might also like