You are on page 1of 6

Department of Computer Science & Engineering

Sub- Theory of Computation

Graded Assignment-1

Name:- Ajay kumar

Rollno:-05

Batch:-A(1)

16/02/17
Q1. Design a Mealy machine with n states (N= (1 st Digit of DOB + 2nd Digit of DOB+ Month
of Birth) mod 10) with a, b as input characters and 0 & 1 as out parameters, convert the
same into a Moore Machine. Design the state diagram of both.

Ans:-

Date Of Birth:- 03/01/1996

So, N=(0+3+1)%10=4={q1, q2, q3,q4}


Input Characters =a, b
Output Characters =0,1

MEALY MACHINE:-
Present
Input =a Input=b
State
Next Output Next State Output
State
q1 q3 0 q2 0

q2 q1 1 q4 0

q3 q2 1 q1 1

q4 q4 1 q3 0

STATE DIAGRAM Of Mealy Machine:-

Step 1:- At the first stage we see into the next state column for any state like qi and determine
the number of different output associated with qi in that column.
Step 2:- Now we split qi, into the number of the such states, which are equal to the number of
different output associated with qi taking qi as the next state

Output of q1=1(for input a)

Output of q1=1(for input b)


Both the Outputs are Same

Output of q2=1(for input a)

Output of q2=0(for input b)


Both the Outputs are Different

Output of q3=0(for input a)

Output of q3=0(for input b)


Both the Outputs are Same

Output of q4=1(for input a)

Output of q4=0(for input b)


Both the Outputs are Different

In the above, q1 and q3 cannot be splitted because they have the same output for the given input
a and b.

But the states q2 and q4 have the different output for the given input a and b. So, we split q2 into
q20 and q21 And Similarly q4 is splitted into q40 and q41.
Present
Input =a Input=b
State
Next Output Next State Output
State

q1 q3 0 q2 0

q20 q1 1 q4 0

Q21 Q1 1 Q40 0

q3 q2 1 q1 1

q4 q4 1 q3 0

Q41 Q41 1 Q3 0

Step 3:- In the previous table , each state in the next column is associated with single output . We
reconstruct the table so that we have only one output column which show single output
associated with each state in the present state column.

Present State Input =a Input =b Output

Next State Next State

Q0 Q3 Q20 0

Q1 Q3 Q20 1

Q20 Q1 Q40 0

Q21 Q1 Q40 1

Q3 Q21 Q1 0
Q40 Q41 Q3 0

Q41 Q41 Q3 1

Q2. Design an FA to parse an input string as 4 binary place of each of the last
4 digits of your enrollment. Find out of it is DFA or NDFA, if it is an NDFA
then convert it into a DFA. Also draw the transitional table and tuple set for
both (FA & DFA).

Ans:-

Enrollment No.:- CP10101408210

8:- 1000

2:-0010

1:-0001

0:-0000

TRANSITIONAL TABLE:-

State INPUT
0 1
Q0 Q0 Q1
Q1 Q2 Q1
Q2 Q3 Q0
Q3 Q1 Q3

Transition is shown as (q,a)


(i) For String 8(1000):-

Q0 1 Q1 0 Q2 0 Q3 0 Q1

Not Parseable
(ii) For String 2(0010):-

Q0 0 Q1 0 Q2 1 Q3 0 Q1

Parseable

(i) For String 1(0001):-

Q0 0 Q1 0 Q2 0 Q3 1 Q1

Not Parseable

(i) For String 0(0000):-

Q0 0 Q1 0 Q2 0 Q3 0 Q1

Not Parseable

You might also like