Vous êtes sur la page 1sur 6

1.

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.

For = {a, b} construct dfas that accepts the sets consisting of


a. all strings with exactly one a.
As done in class:
a,b
b
b
a

q0

q1

q2

b. all strings with at least one a.


b
a, b
q0

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

Give dfas for the languages


a. L = {ab5wb2 : w {a, b}*}
a

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

c. L = {w1abw2 : w1 {a, b}*, w2 {a, b}*}


This is any string containing ab somewhere in it.
b
a
a,b
b
a

7. Find dfas for the following languages on = {a, b}


a. L = {w : |w| mod 3 = 0}
a,b
0
1
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

c. L = {w : na(w) mod 3 > 1}


b
b
a
1
0
a

a
b

d. L = {w : na(w) mod 3 > nb(w) mod 3}


a
a
20
10
00
b a
b
b
a
a
11
b
01
21
b
b
b a
b
b
a
a
12
02
22
a
e.
f.

L = {w : (na(w) nb(w)) mod 3 > 0}


L = {w : (na(w) + 2nb(w)) mod 3 < 2}

8. A run in a string is a substring of length at least two, as long as possible and


consisting entirely of the same symbol. Find dfas for the following languages over
{a, b}:
a. L = {w: w contains no runs of length less than four}

aa

b
b

b
b

a
bb

b
b

bbb

aaaa

trap

a,b
b

aaa

bbbb

b. L = {w: every run of as has a length of either two or three}

a
b

c. L = {w : there are at most


a

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

b. all strings containing 00 but not 000


1

0
1

0
1

c. The leftmost symbol differs from the rightmost


0
1
1
0
0
0
1
0
1
1
d. Every substring of four symbols has at most two 0s

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

11. Show that the language L = {vwv: v, w {a,b}*. |v| = 2} is regular.


a.b
a
a
a
a.b
a
b
a
b
a.b
a
a
b
b
a.b
b
b
b
12. Show that L = {an: n 4} is regular.
a

13. Show that the language L = {an: n 0, n 4} is regular.


a

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.

Vous aimerez peut-être aussi