Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

CS 3800 Homework 3 Solutions - All Answers are Correct

Beoordeling
-
Verkocht
-
Pagina's
5
Cijfer
A+
Geüpload op
30-01-2023
Geschreven in
2022/2023

Homework 3 (due Friday, January 31) Instructions: This homework is to be submitted on GradeScope as a single pdf (not in parts) by 11:59 pm on the due date. You may either type your solutions in a word processor and print to a pdf, or write them by hand and submit a scanned copy. Do write and submit your answers as if they were a professional report. There will be point deductions if the submission isn’t neat (is disordered, difficult to read, scanned upside down, etc. . . .). Begin by reviewing your class notes, the slides, and the textbook. Then do the exercises below. Show your work. An unjustified answer may receive little or no credit. Read: 1.3 (for Tuesday), 1.4 (for Friday). 1. [15 Points] Consider the language L = {w ∈ {a, b} ∗ | w has even length and an odd number of a’s} This language is the intersection of the simpler languages L1 = {w ∈ {a, b} ∗ | w has even length} and L2 = {w ∈ {a, b} ∗ | w has an odd number of a’s}. (a) Give the diagram of a DFA accepting L1. Solution: qa s a b a fa b ε qb b fb a ε NFA22 Final CS 3800 Fall 2018 b a qa s a b a fa b b qb b fb a a DFA24 Final CS 3800 Fall 2018 qa s a b a fa a, b qb b fb a, b a, b q1 a, b a, b q2 a, b DFA25 Final CS 3800 Fall {1, 2, 3} {2, 3} ∅ b, c b a b a, c {1} {2} c a a, b, c c b a Final CSF DFA26 MT∅ a, b b a {1} MT1 CS3800{1{1, 2, 3} a {1} {1, 3} b a a b b even length odd length a, b a, b DFA32 (b) Give the diagram of a DFA accepting L2. Solution: qa s a b a fa b ε qb b fb a ε NFA22 Final CS 3800 Fall 2018 b a qa s a b a fa b b qb b fb a a DFA24 Final CS 3800 Fall 2018 qa s a b a fa a, b qb b fb a, b a, b q1 a, b a, b q2 a, b DFA25 Final CS 3800 Fall {1, 2, 3} {2, 3} ∅ b, c b a b a, c {1} {2} c a a, b, c c b a Final CSF DFA26 MT1 C∅ a, b b a {1} b a MT1 CS3800-20{1, 2{1, 2, 3} a {1} {1, 3} b a a b b beven length odd length a, b a, b DFA32 DFA33 b even a odd a’s ’s a a b (c) Use the construction of Lecture 5a to give the state diagram of a DFA for L. Solution: qa s a b a fa b ε qb b fb a ε NFA22 Final CS 3800 Fall 2018 b a qa s a b a fa b b qb b fb a a DFA24 Final CS 3800 Fall 2018 qa s a b a fa a, b qb b fb a, b a, b q1 a, b a, b q2 a, b DFA25 Final CS 3800 Fall {1, 2, 3} {2, 3} ∅ b, c b a b a, c {1} {2} c a a, b, c c b a Final CSF DFA26 MT1∅ a, b b a {1} b even length odd length a, b a, b DFA32 DFA33 b even a’s odd a’s a a b DFA34 even length, odd a’s even length, even a’s odd length, odd a’s odd length, even a’s a b a b a b a b 2. [8 Points] Let L = {w ∈ {a, b} ∗ | w 6= a and w 6= b}. Page 1 of 5 CS 3800 Hwk 3 Spring 2020 (a) Give the state diagram of a DFA for the complement L of L. Solution: L = {w ∈ {a, b} ∗ | w = a or w = b}. b a a b a b a, b MT1 CS F DFA29 MT1 CS F DFA28 b a a b a b a, b b b a ε 019F DFA28 DFA 3X a, b a, b a, b DFA 3X a, b a, b a, b (b) Apply the methods of Lecture 5a to give the state diagram of a DFA for L. Solution: b a a b a b a, b MT1 CS F DFA29 MT1 CS F DFA28 b a a b a b a, b b b a ε 2019F DFA28 DFA 35 a, b a, b a, b DFA 36 a, b a, b a, b 3. [5 Points] Which, if any, of the strings below are accepted by the following nondeterministic finite automaton?

Meer zien Lees minder
Instelling
Vak

Voorbeeld van de inhoud

CS 3800 Spring 2020
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

Geschreven voor

Vak

Documentinformatie

Geüpload op
30 januari 2023
Aantal pagina's
5
Geschreven in
2022/2023
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

$8.49
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
ExamsConnoisseur Self
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
587
Lid sinds
3 jaar
Aantal volgers
344
Documenten
1492
Laatst verkocht
1 week geleden

4.2

68 beoordelingen

5
40
4
11
3
13
2
1
1
3

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen