Professional Documents
Culture Documents
Please note that there is more than one way to answer most of these questions. The following only represents a sample solution. Problem 1: Linz 2.1.7(b)(c)(g), 2.2.7. and 2.2.11
2.1.7: Find dfas for the following languages on = {a, b}
(b): L = {w : |w| mod 5 = 0} A dfa for L is given by the following transition graph:
a,b
a,b
(c): L = {w : na (w) mod 3 > 1} A dfa for L is given by the following transition graph:
b a b a
(g): L = {w : |w| mod 3 = 0, |w| = 6} A dfa for L is given by the following transition graph:
a,b
a,b
a,b
a,b a,b
a,b
a,b
a,b
a,b
a,b
2.2.7: Design an nfa with no more than ve states for the set {ababn : n 0} {aban : n 0}.
An nfa for the set is given by the following transition graph:
a a b b
2.2.11: Find an nfa with foour states for L = {an : n 0} {bn a : n 1}.
An nfa for L is given by the following transition graph:
b a
r (qr , a) = , if a = Now we will show that LR = L(NR ). w LR i wR L i there is a walk on the transition graph of N with label wR from qn to some qi F i there is a walk on the transition graph of NR from qr to qi with label and a walk from qi to qn with label w (Following the reverse of every transition in the original graph) i w L(NR ). Since LR can be represented by a nfa, it is regular (by equivalence of nfa to dfa, and dfa to regular language).
b a a b b a a a b b b a b a b a a a
b b
b a
b a b a a a a
a b b a b a a,b a b b a b a b b a a b a b b a a b a b a b b b a
a b b a b b a a b b a b b a b a a a a a b b b a,b a b a a b b a
0 {0} {0,2}
1 0 0 1 0 0 0 1
{0,1,2}
{1}
{2}
2.3.8: Find an nfa without -transitions and with a single nal state that accepts L = {a} {bn : n 1}.
Noting that L, we can use the technique given in 2.3.9 (Problem 2) and we get the nfa given / by the following transition graph:
b
b a,b a