Compiler Design and Construction - Old Questions

3.  Convert the regular expression '0 +(1+ 0)*00' first into NFA and then into DFA using Thomson’s and Subset Construction methods.

6 marks | Asked in 2068

Given RE:

+(1+ 0)*00

Converting into NFA using Thomson's method:

For 0,


For 1,


For 1+0


For (1+0)*


For (1+0)*00


For 0+(1+0)*00

Which is the required NFA. Now converting it into a DFA:

The initial state of the NFA is {A}.

Therefore, the initial state of the DFA is:

S0∈-closure({A}) = {A, B, C, D, E, F, J}

Here,

Σ = {0, 1)

Now,

Dtran[S0, 0] = ∈-closure(move(S0, 0)) = ∈-closure({H, K, M}) = {D, E, F, H, I, J, K, M, N} = S1 (say)

Dtran[S0, 1] = ∈-closure(move(S0, 1)) = ∈-closure({G}) = {D, E, F, G, I, J} = S2

Dtran[S1, 0] = ∈-closure(move(S1, 0)) = ∈-closure({H, K, L}) = {D, E, F, H, I, J, L, N} = S3

Dtran[S1, 1] = ∈-closure(move(S1, 1)) = ∈-closure({G}) = {D, E, F, G, I, J} = S2

Dtran[S2, 0] = ∈-closure(move(S2, 0)) = ∈-closure({H, K}) = {D, E, F, H, I, J, K} = S4

Dtran[S2, 1] = ∈-closure(move(S2, 1)) = ∈-closure({G}) = {D, E, F, G, I, J} = S2

Dtran[S3, 0] = ∈-closure(move(S3, 0)) = ∈-closure({H, K}) = {D, E, F, H, I, J, K} = S4

Dtran[S3, 1] = ∈-closure(move(S3, 1)) = ∈-closure({G}) = {D, E, F, G, I, J} = S2

Dtran[S4, 0] = ∈-closure(move(S4, 0)) = ∈-closure({H, K, L}) = {D, E, F, H, I, J, L, N} = S3

Dtran[S4, 1] = ∈-closure(move(S4, 1)) = ∈-closure({G}) = {D, E, F, G, I, J} = S2

Here, S1 & S3 are the accepting state of DFA, since N is a member of both S1 & S3 states.

The equivalent DFA is;