0% found this document useful (0 votes)
137 views8 pages

Solutions To The Exercises On Finite Automata

The document provides solutions to exercises on finite automata. It includes solutions for recognizing languages based on strings containing certain substrings, having a minimum number of characters, being empty, and ending or containing certain substrings. Finite state automata are presented that recognize these languages. Deterministic finite state automata are also given that recognize the same languages as given non-deterministic finite state automata.

Uploaded by

Ser Gutie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views8 pages

Solutions To The Exercises On Finite Automata

The document provides solutions to exercises on finite automata. It includes solutions for recognizing languages based on strings containing certain substrings, having a minimum number of characters, being empty, and ending or containing certain substrings. Finite state automata are presented that recognize these languages. Deterministic finite state automata are also given that recognize the same languages as given non-deterministic finite state automata.

Uploaded by

Ser Gutie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Solutions to the exercises on Finite Automata

April, 2007

Exercise on slide 4
Given a state diagram of FA M1. Is 000111 accepted, is 10110?

Solution
000111 and 10110 are accepted.

Exercises on slide 7
Exercise 1
What is the language recognized by M1?

Solution
The language recognized by M1 is the set of all strings that contain 11 as a substring.

Exercise 2
1. Define a recognizer for {w {0, 1} : w contains at least four 1, s}.
2. Is there a recognizer for {w {0, 1} : w contains the substring 1010}?

Solution
Such recognizers are on Figure 3 for task 1 and on Figure 4 for task 2.

1
0 0

1 1
q1 q2 q3
0

Figure 1. M1

1
0 0 0 0 0,1

1 1 1 1
q1 q2 q3 q4 q5

Figure 3. Recognizer for {w {0, 1} : w contains at least four 1, s}

1
0,1
0
q2 1
1 0
0 q4 q5
1
q1 0
q3

Figure 4. Recognizer for {w {0, 1} : w contains the substring 1010}

Exercise 3
Let = {0, 1}. Define a recognizer for .

Solution
Such recognizer is on Figure 5.

Exercise 4
Let = {0, 1}. Define a recognizer for {}.

Solution
Such recognizer is on Figure 6.

Exercise on slide 11
What is the language recognized by N1 (Fig.7) and by N2 (Fig.8)?

0,1

q1

Figure 5. Recognizer for

2
0,1

0,1
q1 q2

Figure 6. Recognizer for {}

0,1

1 0,e 1
q1 q2 q3 q4

Figure 7. N1

Solution
L(N1) is the set of strings over {0, 1} ending on 11 or 101
L(N2) = is the set of strings over {0, 1} containing 101

Exercise on slide 13
Show a sequence of states in N2 that makes the string 1011 be accepted.

Solution
q1 , q2 , q3 , q4 , q5 , q5 , where: q2 (q1 , 1) = {q1 , q2 }
q3 (q2 , 0) = {q3 }
q4 (q3 , 1) = {q4 }
q5 (q4 , ) = {q5 }
q5 (q5 , 1) = {q5 }
Concurrent computation steps are: {q1 , 1011} {(q1 , 011), (q2 , 011)} {(q1 , 11), (q3, 11)}
{(q1 , 1), (q2, 1), (q4 , 1)} {(q1 , ), (q2, ), (q2 , 1), (q5 , 1)} {(q1 , ), (q2 , ), (q2 , 1), (q5, )}

0,1 0,1

1 0 1 0,e
q1 q2 q3 q4 q5

Figure 8. N2

3
Exercises on pages 653-655 in Discrete Mathematics and Its
Applications
Exercise 3
Find all pairs of sets of strings A and B for which AB = {10, 111, 1010, 1000, 10111, 101000}.

Solution
a) A = and B = {10, 111, 1010, 1000, 10111, 101000}
b) B = and A = {10, 111, 1010, 1000, 10111, 101000}
c) A = {1} and B = {0, 11, 010, 000, 0111, 01000}
d) A = {1, 101} and B = {0, 11, 000}
e) A = {, 10} and B = {10, 111, 1000}

Exercises 12-16
In exercises 12-16 find the languages recognized by the given deterministic finite-state automa-
ton.

Solutions
12) ((1 01 0)(0 1) )
13) 0 (1(0 1))(0 1)
14) 01
15) 0 11
16) 1 00 (1(0 1)(0 1) ) 1 00

Exercise 17,19,21
In exercises 17,19,21 find the languages recognized by the given nondeterministic finite-state
automaton.

Solutions
17) 01 11 0
19) ((0 00 1)1 )
21) 10 10 10

Exercise 24
Find a deterministic finite-state automaton that recognizes the same language as the nondeter-
ministic finite-state automaton in Exercise 19.

Solution
Let such DFA be M = (Q, , , q0 , F ). Where Q {, {s0 }, {s1}, {s2 }, {s0 , s1 }, {s0, s2 }, {s1, s2 }, {s0 , s1 , s2 }},
= {0, 1} and q0 = {s0 }. Let us make the transition function :
(q0 , 0) = {s1 , s2 } = q1

4
1

0 1

0 1 0,1
q1 q3 q4
0 0
q0 q2
1

Figure 9. Deterministic finite-state automaton for Exercise 24

(q0 , 1) = = q2
(q1 , 0) = {s1 } = q3
(q1 , 1) = {s2 } = q4
(q2 , 0) = q2
(q2 , 1) = q2
(q3 , 0) = {s1 } = q3
(q3 , 1) = {s2 } = q4
(q4 , 0) = = q2
(q4 , 1) = {s2 } = q4 .
As s0 and s2 are accept states, F = {q0 , q1 , q4 }. The required deterministic finite-state automa-
ton is represented on Figure 9.

Exercise 26
Find a deterministic finite-state automaton that recognizes the same language as the nondeter-
ministic finite-state automaton in Exercise 21.

Solution
Let such DFA be M = (Q, , , q0 , F ). Where Q {, {s0}, {s1 }, {s2 }, {s3 }, {s0, s1 },
{s0 , s2 }, {s0, s3 }, {s1 , s2 }, {s1 , s3 }, {s3 , s2 }, {s0 , s1 , s2 },
{s0 , s1 , s3 }, {s0, s3 , s2 }, {s3, s1 , s2 }, {s0 , s1 , s2 , s4 }},
= {0, 1} and q0 = {s0 }. Let us make the transition function :
(q0 , 1) = {s1 } = q1
(q0 , 0) = {s2 } = q2
(q1 , 0) = {s1 , s2 } = q3
(q1 , 1) = {s3 } = q4
(q2 , 0) =
(q2 , 1) = = q2 , here all transitions from q2 go to , therefore state q2 is a state for
(q3 , 0) = {s1 , s2 } = q3
(q3 , 1) = {s3 } = q4
(q4 , 0) = {s2 , s3 } = q5
(q4 , 1) = {s2 } = q2
(q5 , 0) = {s2 , s3 } = q5
(q5 , 1) = {s2 } = q2 .

5
0 0

q3 q5
0 1 0 0,1
1
1 q4 1
q1
1 q2
q0
0

Figure 10. Deterministic finite-state automaton for Exercise 26

0,1
q1
0 0,1
q0 1 q2

Figure 11. Deterministic finite-state automaton that recognizes {0}

As s1 and s3 are accept states, F = {q1 , q3 , q4 , q5 }. The required deterministic finite-state


automaton is represented on Figure 10.

Exercise 27
Find a deterministic finite-state automaton that recognizes each of the following sets.
a) {0}
b) {1, 00}
c) {1n |n = 2, 3, 4, ...}

Solution
a) Figure 11
b) Figure 12
c) Figure 13

0,1
1 q2
0,1
q0 0
0
1 q3
q1

Figure 12. Deterministic finite-state automaton that recognizes {1, 00}

6
1

q2
0,1
1 0

q1 0
1 q3
0
q0

Figure 13. Deterministic finite-state automaton that recognizes {1n |n = 2, 3, 4, ...}

0
q0 q1

Figure 14. Nondeterministic finite-state automaton that recognizes {0}

Exercise 28
Find a nondeterministic finite-state automaton that recognizes each of the languages in Exercise
27, and has fewer states, if possible, than the deterministic automaton you found in that exercise.

Solution
a) Figure 14
b) Figure 15
c) Figure 16

1
q0 q2
0 0
q1

Figure 15. Nondeterministic finite-state automaton that recognizes {1, 00}

7
1

1 1
q0 q1 q2

Figure 16. Nondeterministic finite-state automaton that recognizes {1n |n = 2, 3, 4, ...}

You might also like