Tutorial 5
Tutorial 5
Automata
1. Consider the following NFA. Determine whether the following strings are IN or NOT IN the language by
putting/writing them in the right column in Table 2.
a q2 b
a
q1 q3
c c
q4
a, b, c, ab, ac, bc, aab, acc, acab, ca, cb, abab, abaab, cc, cab, caab, caa, ccab, ccac, abacab
Table 2.
a a a
q0 q1 q2 q3
b
b
a) Give a state diagram (FA) for this state table. Is this a deterministic FA or not?
b) Trace the computations that process the strings aa, bb and abba.
d) Give a regular expression for the language accepted by M.
4. Write a regular expression and a finite automata for L1 = {wuw: |w| = 2; w, u ∈ Σ*}. Σ = {a, b}.
90 | P a g e
5 Push-down
Automata
5. Consider the languages in Table 2. Match them with the Regular Expressions (RE) from Table 3 and Finite Automata (FA) from Table 4. The
alphabet is = {a, b}.
a
1. All strings. 5. (a + b) 4. q0 q1
b
a, b a, b a, b
All strings that start with zero or more a‘s
3. 7 ba(a + b)* 13 a a
and followed by zero or more b‘s. q0 q1 q2
a, b
All strings that contain only zero or more
4. 1. (a + b)* 10 q0 q1
substring ab.
a, b
a
6. All strings that contain the substring ba. 3. a*b* 5. q0 q1
b
a, b a, b
7. All strings starting with ba. 4. (ab)* 6 b a
q0 q1 q2
91 | P a g e
5 Push-down
Automata
a, b
8. All strings ending with ba. 12 (a + b)*a(a + b)*a(a + b)* 7 b a
q0 q1 q2
a, b
9. All strings that begin AND end with ba. 13 ((a + b)(a + b)) 1.
q0
a, b
10. All strings of even length 14 (a + b)*b(a + b) 2. a, b
q0 q1
a b
11. All strings containing exactly two a’s. 15 (a + b)b(a + b)* 3. b
q0 q1
b b b
12. All strings containing at least two a’s. 8 (a + b)*ba 11 a a
q0 q1 q2
a, b
13. All strings of length two. 9 ba(a + b)*ba 8 b a
q0 q1 q2
a, b
The language of all strings with b as the
14. 10 ((a + b)(a + b))* 9 b a b a
second last letter. q0 q1 q2 q3 q4
a, b
The language of all strings with b as the
15. 11 b*ab*ab* 14 b a, b
second letter. q0 q1 q2
92 | P a g e
5 Push-down
Automata
6. Consider the Regular Expressions in Table 8. Match them with the Finite Automata (FA) from
Table 9. The alphabet is = {a, b}.
Table 8. Table 9.
Matched
No. Regular Expressions (RE) No.
Finite Automata (FA)
a a, b
1. (a + b)*a 4 q0
b
q1
b
q2
a
b b b a, b
2. a*b+ 3 a a a
q0 q1 q2 q3
a, b
3. b*ab*ab* 1 a
q0 q1
q1
b b
4. (a + b)*bb(a + b)* 5 q0
b a
q2
5. (bb + ba)* 2 q0
b
q1
b
a, b a, b
b
q0 q1
6. (ab)*ba 9
a
a
q2
b
a
7. (ab)*(ba)* 10 q0 q1
b
b
a
q0 q6
8. (b + bba)*a 8 b a
b
q3 q4
a
q0 b q1
a
q0 b q1
10. (b + ab)* 6 b
a
q2 q3
93 | P a g e