Beruflich Dokumente
Kultur Dokumente
September 2006
q1
q2
Just follow the bouncing ball. Starting at the initial state, just follow the arrows and see
where you wind up. 0001 leaves us in state q1, 01001 leaves us in state q1, and 0000110
leaves us in state q2. So the first two are accepted and the last one is rejected.
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.
When building a DFA, remember that the states have meaning. This language
has two possibilities for as: no as or at least one a. It has four possibilities for
bs: no bs, 1 b, 2 bs or more than two bs. So there are two times four, or eight
states. Ill label the states to point out their meaning. q00: no as or bs, q10: at
least one a but no bs, q01: no as and 1 b, etc.
b
q00
a
q01
b
a
q11
a
q02+
a
q10
q02
q12
a
q12+
a,b
September 2006
e. all the strings with exactly two as and more than two bs.
q00
b
a
q11
b
a
q02
b
q02+
q12
q21
q12+
q2+1
b
b
a
q22
q2+0
b
q20
b
q01
q10
q22+
q2+2
b
q2+2++
a,b
3. Show that if we change Figure 2.6, making q3 a nonfinal state and making q0, q1, q2
final states,L the resulting dfa accepts
. This will be true for any dfa. If we switch the final and
non-final (non-accepting) states, then any string that leaves us in an accepting state in the original now
leaves us in a non-final state (and vice-versa) because we have switched around which of the states is a final
state. By definition then, the language accepted by the new machine is the complement of the language
accepted by the original one.
4. Generalize the statement in exercise 3.
We just did!
5. Give dfas for the languages
a. L = {ab5wb2 : w {a, b}*}
a
b
a
b
a
b
b
a,b
b. L = { abnam : n 2, m 3}
a
b
a,b
b
a
b
a
a
a,b
a
b
a
b
September 2006
0 a,b
a,b
2
a,b
4
a,b
a,b
a
b
aa
aaa
b
b
b
b
trap
a,b
bb
bbb
aaaa
bbbb
b
a
0
b
b
a
a
a
b
b
2+
a
b
a
State 0: no runs, State 1: one run, State 2: two
runs, State 3: more than two
runs (reject)
September 2006
0,1
1
1
0,1
0
0
000
0000
0,10,
1
0,10,
1
01
001
00
010
10
011
100
1
1
0
101
11
110
111
1
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1
1111
0
1
1
2
September 2006
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.
Same picture as 14, but states 3, 6, 9 and 12 are the only accepting states.