W. Schnyder 1/24/2020
Homework 3
(due
ε
ε Friday, January
a
a 31)
b
b
fa qa b fa qa b
a fa qa b a fa qa b
a a
a, b ∅
∅
a a
Instructions: s This homework a is to be submitted on GradeScope s as aa single pdf (not in parts)a,by b
s ε s a
11:59 pm on the due ε a
b date. f
You may either type your solutions
qb b in
f
a word processor and print to
qb
b b a b b a
f
a pdf, or write them by hand and submit
b q b a a scanned copy. Do write and submitfb qb ayour answers as
a
if they were a professional report. εb There will be point deductions b if the bb submission isn’t neat (is
b b b
disordered, difficult fFinal
to read, scanned qupside b down, etc. . . .). fa q
aNFA22 CS 3800 Fall a 2018
aDFA24 Final CS 3800 Falla 2018b
a
NFA22 Final CS 3800 Fall 2018 ∅ MT
DFA24 Final CS 3800 Fall 2018 a, b
Begin by reviewing
s your class anotes, the slides, and the s textbook. Then a do the exercises below.
Show your work. An unjustified ε answer may receive little or no credit. a
b a, b b a
fb a, b qb ab fb qb a a
Read: 1.3 (for Tuesday), 1.4 (for a, b Friday). a,
fa qa q1 a
a fa b qa q1 b{1} b a {1, 2, 3} a
a {1} c {1, 2, 3} a
NFA22
1. [15 Points] Consider
s Final CS 3800
the language a Fall 2018 a, b c c M
a a, ba, b DFA24 Final CS 3800 Fall 2018 c
s a, b
a, b a, b b, c {2, 3} b {1}
b {1}
Lb= {wfb∈fb{a, b}∗ | wqbhas qb even length
q2
q2 b, c an odd number
and {2, 3} of a’s} b
a,a,b b a b a
a,bb a b
This language is the intersection b of the a, bsimpler languages L1 = {w ∈ {a, b}∗ | w has even length}
fa
DFA25 Final CS 3800 qa Fall q1 ∅ a {2}
a ∗ {1,
and L2 = {w ∈ {a, b} Final
DFA25 | w has
CS 3800 an Fall
odd number a, b,a’s}.
of c ∅ {1} a, c {2}2, 3} b a
a, b, c ca, c b
s a a, b c
(a) Give the diagram of aa,DFA b accepting
a, b L1 .
b b, c Final CS3800-2018F
{2, 3} DFA26 b {1}
Solution: fb qb q2 Final CS3800-2018F DFA26
a, b a b
a, b a, b
b
even length odd length
even length DFA25 Final oddCS 3800 Fall
length ∅ {2}
a, b, c a, c b
a, b
a, b
(b) Give the diagram DFA32
DFA32of a DFA accepting L2 . Final CS3800-2018F DFA26
Solution: a, b b
b
b b
a {1, 2, 3}
even length a odd length {1, 2, 3}
a b b
even a’s odd a’s a b b
even a’s a, b odd a’s
a a
DFA32
a {1} a
{1} {
DFA33
DFA33
(c) Use the construction of Lecture 5a to give the state diagram of a DFA for L.a b
a {1, 3} b
Solution: {1, 3}
a
even length, even a’s odd length, odd a’s MT1 CS3
MT1 CS380
a
b b b b
a
odd length, even a’s even length, odd a’s
a
DFA34
2. [8 Points] Let L = {w ∈ {a, b}∗ | w 6= a and w 6= b}.
Page 1 of 5
, a a a a
a a a a
a b a, b a b a, b
a b a, b a b a, b
b b b b
b b b b
CS 3800 Hwk 3 Spring 2020
MT1
MT1CSCS3800-2019F
3800-2019FDFA28
DFA28 MT1
MT1CSCS3800-2019F
3800-2019FDFA29
DFA29
(a) Give the state diagram of a DFA for the complement L of L.
Solution: L = {w ∈ {a, b}∗ | w = a or w = b}.
a, b a, b
a, b a, b a, b
a, b
b
b
b
b
a
a(b) Apply theDFA 3X
methods
DFA 35 of Lecture 5a to give the state diagram of a DFA for L.
ε Solution:
a, b a, b
ε a, b
a, b a, b
a, b
DFA
DFA3X
36
3. [5 Points] Which, if any, of the strings below are accepted by the following nondetermin-
istic finite automaton?
a b a
019F
2019FDFA28
DFA28 start
ε, ε → $
p
ε, ε → b
q
ε, $ → ε accept
a ε b ε q0
ε, ε → bb a, ε → a start 0 ∪ 1(01* 0
a, b → ε
b, ε → b ε
b b, a → ε
accept NFA_REG3a
NFA26 words with more a’s than b’s
(a) aa
Solution: not
0 accepted
1 0 0 1 start
ε
(b) abastart ε q0 q1 q2 1 start q0 q1 01* 0 (0 ∪ 1(01* 0)*1
Solution: accepted1via a ε b0 a 1
ε ε accept NFA_REG
(c) abbaccept accept NFA_REG2a
NFA_REG1a
Solution: not accepted
(d) ab
Solution:
ε, ε accepted
→ $ q1 ε,via
ε →aε ε bq2 ε, ε → ε q3 ε, ε → ε q4 ε, $ → ε
s f
(e) abab
a, ε → a
Solution: accepted via a b,ε ab→a εε b b, ε → b a, b → ε
Pb7 MT2 F19
4. [8 Points] Describe the language L ⊆ {a, b}∗ that is accepted by the nondeterministic
automaton
ε ε ε
a a a, ε
b b b
Solution: L = {ab, abb, abbb, bbb}
Page 2 of 5