Académique Documents
Professionnel Documents
Culture Documents
Which of the following strings 0001, 01001, 0000110 are accepted by the dfa in Figure
2.1?
0
1
0
0
q0
q1
q2
1
2.
q0
q1
q2
q1
c. all strings with no more than three as. (notice how the states indicate # of
as).
b
b
b
b
a,b
a
a
a
a
q2
q0
q3
q1
q4+
d. all strings with at least one a and exactly two bs.
e. all the strings with exactly two as and more than two bs.
q00
b
q01
q10
q11
b
q02
b
q02+
a
a
b
a
q20
q12
q12+
q21
q2+1
b
q22
q2+0
q22+
q2+2
b
q2+2++
a,b
b
a
b
b
a,b
b. L = { abnam : n 2, m 3}
a
b
b
a
b
a
a
b
a,b
a,b
a,b
b. L = {w : |w| mod 5 0}
1
0 a,b
a,b
2
a,b
4
a,b
a,b
a
b
aa
b
b
b
b
a
bb
b
b
bbb
aaaa
trap
a,b
b
aaa
bbbb
a
b
b
b
a
b
b of
two
b runs
1
a
a
a,b
a,b
as of length three}
b
a
b
a
b
a
b
2+
State 0: no runs, State 1: one run, State 2: two runs, State 3: more than two
runs (reject)
d. L = {w : there are exactly two runs of as of length three}
Same as in part c, but only state 2 and the previously accepting states after it
would now be accepting.
9. Consider the sets of strings on {0, 1} defined by the requirements below. Construct
dfas.
a. Every 00 is followed immediately by a 1
1
0,1
1
1
0,1
0
1
0
1
0
1
e. All strings of length five or more in which the fourth symbol from the right end is
different than
the leftmost symbol.
f. All strings in which the leftmost two symbols and the righmost two symbols are
identical.
g. All strings of length four or greater in which the leftmost 3 symbols are the
same, but different from the rightmost symbol.
10. Construct a dfa that accepts strings on {0, 1} if and only if the value of the string,
viewed as the binary representation of a number, is equal to zero modulo 5.
1
0
0
1
1
2
14. Show that the language L = {an: n is either a multiple of three or a multiple of 5} is
regular.
a
a
a
a
a
a
4
1
5
6
2
7
a
3
a
0
8
a
a
a
a
a
a
a
10
13
11
14
9
12
Since 15 is the least common multiple of 3 and 5, we can do modulo 15 arithmetic with
the accepting states as shown above.
15. Show that the language L = {an: n is a multiple of three but not a multiple of 5} is
regular.