SlideShare a Scribd company logo
Homework One Solution– CSE 355
Due: 31 January 2011
Please note that there is more than one way to answer most of
these questions. The following only represents a sample solution.
Problem 1: Linz 2.1.7(b)(c)(g), 2.2.7. and 2.2.11
2.1.7: Find dfa’s for the following languages on Σ = {a, b}
(b): L = {w : |w| mod 5 = 0}
A dfa for L is given by the following transition graph:
a,b
a,b
a,b
a,ba,b
(c): L = {w : na(w) mod 3 > 1}
A dfa for L is given by the following transition graph:
a
a
a b
b
b
1
(g): L = {w : |w| mod 3 = 0, |w| = 6}
A dfa for L is given by the following transition graph:
a,b a,b a,b a,b
a,b
a,ba,ba,b
a,b
a,b
2.2.7: Design an nfa with no more than five states for the set {ababn
: n ≥
0} ∪ {aban
: n ≥ 0}.
An nfa for the set is given by the following transition graph:
a b
b
b
a
a
λ
2.2.11: Find an nfa with foour states for L = {an
: n ≥ 0} ∪ {bn
a : n ≥ 1}.
An nfa for L is given by the following transition graph:
b
b
aλ
a
2
Problem 2: Linz 2.39 and 2.3.12
2.39: Let L be a regular language that does not contain λ. Show that there exists
an nfa without λ-transitions and with a single final state that accept L.
Since L is regular there exists a dfa, D = (Q, Σ, δ, q0, F), with an associated transition graph, GD,
such that L(D) = L. We will construct an nfa N = (Q ∪ {qf }, Σ, δ , q0, {qf }) where qf /∈ Q by
giving its transition graph GN as follows:
1. From GD, remove the final label from every final state (making them nonfinal states).
2. Add a new state qf and label it as a final state.
3. For every state qi, if there is a transition from qi to a state in F on input a ∈ Σ, then add a
transition from qi to qf on input a.
Clearly, N has a single accept state, qf , and no λ-transitions (since D is a dfa and we did not add
any λ-transitions in our construction of N). We will now show that L(N) = L. First note that
since λ /∈ L, every w ∈ L can be written as w = va for some v ∈ Σ∗ and an a ∈ Σ.
Now, w = va ∈ L iff there is a walk on GD labeled with w from q0 to qi with qi ∈ F
iff there is a walk on GD labeled with v from q0 to qj and a transition from qj to qi on input a
iff there is a walk on GN labeled with v from q0 to qj and a transition from qj to qf on input a
(since every transition in GD is a transition in GN and from step (3) in the construction of GN )
iff there is a walk on GN labeled with w from q0 to qf
iff w ∈ L(N).
Thus, w ∈ L iff w ∈ L(N). Therefore we conclude that L(N) = L and that for any regular
language that does not contain λ, there exists an nfa without λ-transitions and with a single final
state that accept L.
2.3.12: Show that if L is regular, so is LR
.
Since L is a regular language, we can construct a corresponding dfa, N, such that L(N) = L (For
every regular language, there is a corresponding dfa, by definition, and for every dfa, there is an
equivalent nfa).
By definition, LR consists of all strings in language L in reverse order. We will construct a
nfa, NR, representing LR such that L(NR) = LR. NR will contain an additional start state with
λ-transitions to the final states of N. The direction of every transition in N is reversed. Also, the
start state of N will be the final state of NR. The construction of nfa NR is as follows:
Let N = (Q, Σ, δ, qn, F)
NR = (Q ∪ {q0}, Σ, δr, qr, {qn})
Set of states of NR = set of states of N along with q0 = Q ∪ {qr}
Σ = alphabet of NR = same as N
qr = start state of NR
{qn} = set of final states of NR = start state of N
Transition function:
δr(q, a) = {q1 : δ(q1, a) = q}
δr(qr, λ) = F
3
δr(qr, a) = ∅, if a = λ
Now we will show that LR = L(NR). w ∈ LR iff wR ∈ L iff there is a walk on the transition
graph of N with label wR from qn to some qi ∈ F iff there is a walk on the transition graph of NR
from qr to qi with label λ and a walk from qi to qn with label w (Following the reverse of every
transition in the original graph) iff w ∈ L(NR).
Since LR can be represented by a nfa, it is regular (by equivalence of nfa to dfa, and dfa to
regular language).
Problem 3: Linz 2.1.8
2.1.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. For instance, the string abbbaab
contains a run of b s of length three and a run of a s of length two. Find dfa’s for
the following languages on {a, b}.
(a): L = {w : w contains no runs of length less than four}.
a
b
a
aaaa
a
a
a
a
a
a
b
b
b
b
b
b
b b b b
b
4
(b): L = {w : every run of a s has length either two or three}.
b
a
b
b
bb
aaaa
(c): L = {w : there are at most two runs of a s of length three}.
a a a
a
a
a a
a
a
a
aaaa
a
a,b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
5
(d): L = {w : there are exactly two runs of a s of length 3}.
b
a a a
a
a
aaa
a
a
a a a
a
a
a,b
b
b b
b
b
b
b
b
b
b
b
b
b
b
Problem 4: Linz 2.2.22
2.2.22: Let L be a regular language on some alphabet Σ, and let Σ1 ⊂ Σ be a
smaller alphabet. Consider L1, the subset of L whose elements are made up only
of symbols from Σ1, that is,
L1 = L ∩ Σ∗
1.
Show that L1 is also regular.
Since L is a regular language, there should be a dfa, N, representing L such that L(N) = L, where
N = (Q, Σ, δ, q0, F).
Since L1 is made up of strings with alphabets from Σ1, Σ1 ⊂ Σ, and L1 is a subset of L, L1 contains
only strings that are accepted by L as well. We can construct a dfa, M, for L1 as follows:
1. From the transition graph of N, remove every transition that is labeled with some a /∈ Σ1.
Now we will show that L(M) = L1. w = a1a2 . . . an ∈ L1 iff there is a walk on the transition
graph of N with label w from q0 to some qi ∈ F and every ai ∈ Σ1 iff there is a walk on the
transition graph of M from q0 to qi with label w (it will be the exact same path as it was in N) iff
w ∈ L(M).
Since L1 can be represented by a dfa, it is regular.
6
Problem 5: Linz 2.3.3 and 2.3.8
2.3.3: Convert the following nfa into an equivalent dfa (see textbook for the
diagram).
0
1
0
0
0
0
0
0
0
1
1
1
1
1
1
1
{0,1,2}
{1,2}{0,1}
{1} {2} Φ
{0,2}{0}
2.3.8: Find an nfa without λ-transitions and with a single final state that accepts
L = {a} ∪ {bn
: n ≥ 1}.
Noting that λ /∈ L, we can use the technique given in 2.3.9 (Problem 2) and we get the nfa given
by the following transition graph:
b
b
a
b
a,b
7

More Related Content

What's hot (20)

PPT
Minimization of DFA
kunj desai
 
PPT
DFA Minimization
guest5873b2d
 
PPT
Nfa vs dfa
raosir123
 
PPT
Nfa egs
ankitamakin
 
PPTX
Finite automata-for-lexical-analysis
Dattatray Gandhmal
 
PPTX
Theory of Automata and formal languages unit 1
Abhimanyu Mishra
 
PPTX
Context free grammar
Ratnakar Mikkili
 
PPT
NFA or Non deterministic finite automata
deepinderbedi
 
PDF
Automata theory
Pardeep Vats
 
PPT
Finite automata
Rajesh Yaramadi
 
PPT
Nondeterministic Finite Automata
Adel Al-Ofairi
 
PPT
Finite automata examples
ankitamakin
 
PDF
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Rushabh2428
 
PPT
Dfa h11
Rajendran
 
PPT
Nondeterministic Finite Automat
Adel Al-Ofairi
 
PDF
Theory of Computation FSM Conversions and Problems
Rushabh2428
 
PPTX
Toc(df avs nfa)avishek130650107020
Avishek Sarkar
 
PDF
Automata
Gaditek
 
PDF
Nfa to-dfa
rsivashankari
 
PPTX
push down automata
Christopher Chizoba
 
Minimization of DFA
kunj desai
 
DFA Minimization
guest5873b2d
 
Nfa vs dfa
raosir123
 
Nfa egs
ankitamakin
 
Finite automata-for-lexical-analysis
Dattatray Gandhmal
 
Theory of Automata and formal languages unit 1
Abhimanyu Mishra
 
Context free grammar
Ratnakar Mikkili
 
NFA or Non deterministic finite automata
deepinderbedi
 
Automata theory
Pardeep Vats
 
Finite automata
Rajesh Yaramadi
 
Nondeterministic Finite Automata
Adel Al-Ofairi
 
Finite automata examples
ankitamakin
 
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Rushabh2428
 
Dfa h11
Rajendran
 
Nondeterministic Finite Automat
Adel Al-Ofairi
 
Theory of Computation FSM Conversions and Problems
Rushabh2428
 
Toc(df avs nfa)avishek130650107020
Avishek Sarkar
 
Automata
Gaditek
 
Nfa to-dfa
rsivashankari
 
push down automata
Christopher Chizoba
 

Viewers also liked (7)

PPTX
The Mediterranean Summer Xperience 2011 (AEGEE-Tarragona)
Raül Arlàndez
 
PPT
Pertemuan 3
Yahya D'Liquifaction
 
PDF
Towards a Security-aware Network Virtualization
Achim Friedland
 
DOCX
L aboratorio 2
Cristina Alzate
 
PPT
《学会提问-掌握批判性思维》
wangyuanzhi1
 
PDF
Bob Carlton/Jen Howver - 5 Threads Towards Threshold: What Writing, Publishi...
ECPA Events
 
PPTX
Dr. Ravi Gupta
eletseditorial
 
The Mediterranean Summer Xperience 2011 (AEGEE-Tarragona)
Raül Arlàndez
 
Towards a Security-aware Network Virtualization
Achim Friedland
 
L aboratorio 2
Cristina Alzate
 
《学会提问-掌握批判性思维》
wangyuanzhi1
 
Bob Carlton/Jen Howver - 5 Threads Towards Threshold: What Writing, Publishi...
ECPA Events
 
Dr. Ravi Gupta
eletseditorial
 
Ad

Similar to automata problems (20)

PPTX
symbolic_automata or Advanced Programming Practice.pptx
sudharsr
 
PDF
Automata
Gaditek
 
PPTX
Automata theory - Push Down Automata (PDA)
Akila Krishnamoorthy
 
PDF
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
parmeet834
 
PDF
Chapter 3 REGULAR EXPRESSION.pdf
dawod yimer
 
PDF
FLAT.pdf
AtharvaJoshi930911
 
PPT
2. context free langauages
danhumble
 
PPT
Finite automata examples
ankitamakin
 
PPT
PPT 2.1.1(The Pumping Lemma for Regular sets, Application of the Pumping Lemm...
ArjunMehra32
 
PPT
rs1.ppt
ssuser47f7f2
 
PPTX
Week 3 - to FiniteAutomata DrJunaid.pptx
MFaizan35
 
PPT
Theory of Computation - Lectures 4 and 5
Dr. Maamoun Ahmed
 
PPTX
Resumen material MIT
Rawel Luciano
 
PPTX
AUTOMATA AUTOMATA Automata5Chapter4.pptx
ArjayBalberan1
 
PDF
6-Nfa & equivalence with RE.pdf
shruti533256
 
PPTX
Unit 2 Pumping lemma Unit 2 Pumping lemma
AnshTripathi38
 
PPTX
RegularLanguageProperties.pptx
Ezhumalai p
 
PPT
POST’s CORRESPONDENCE PROBLEM
Rajendran
 
PPT
Chapter 2 limits of DFA NDFA.ppt
ArwaKhallouf
 
PDF
5. NFA & DFA.pdf
TANZINTANZINA
 
symbolic_automata or Advanced Programming Practice.pptx
sudharsr
 
Automata
Gaditek
 
Automata theory - Push Down Automata (PDA)
Akila Krishnamoorthy
 
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
parmeet834
 
Chapter 3 REGULAR EXPRESSION.pdf
dawod yimer
 
2. context free langauages
danhumble
 
Finite automata examples
ankitamakin
 
PPT 2.1.1(The Pumping Lemma for Regular sets, Application of the Pumping Lemm...
ArjunMehra32
 
rs1.ppt
ssuser47f7f2
 
Week 3 - to FiniteAutomata DrJunaid.pptx
MFaizan35
 
Theory of Computation - Lectures 4 and 5
Dr. Maamoun Ahmed
 
Resumen material MIT
Rawel Luciano
 
AUTOMATA AUTOMATA Automata5Chapter4.pptx
ArjayBalberan1
 
6-Nfa & equivalence with RE.pdf
shruti533256
 
Unit 2 Pumping lemma Unit 2 Pumping lemma
AnshTripathi38
 
RegularLanguageProperties.pptx
Ezhumalai p
 
POST’s CORRESPONDENCE PROBLEM
Rajendran
 
Chapter 2 limits of DFA NDFA.ppt
ArwaKhallouf
 
5. NFA & DFA.pdf
TANZINTANZINA
 
Ad

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
PPTX
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
The Future of Artificial Intelligence (AI)
Mukul
 

automata problems

  • 1. Homework One Solution– CSE 355 Due: 31 January 2011 Please note that there is more than one way to answer most of these questions. The following only represents a sample solution. Problem 1: Linz 2.1.7(b)(c)(g), 2.2.7. and 2.2.11 2.1.7: Find dfa’s for the following languages on Σ = {a, b} (b): L = {w : |w| mod 5 = 0} A dfa for L is given by the following transition graph: a,b a,b a,b a,ba,b (c): L = {w : na(w) mod 3 > 1} A dfa for L is given by the following transition graph: a a a b b b 1
  • 2. (g): L = {w : |w| mod 3 = 0, |w| = 6} A dfa for L is given by the following transition graph: a,b a,b a,b a,b a,b a,ba,ba,b a,b a,b 2.2.7: Design an nfa with no more than five states for the set {ababn : n ≥ 0} ∪ {aban : n ≥ 0}. An nfa for the set is given by the following transition graph: a b b b a a λ 2.2.11: Find an nfa with foour states for L = {an : n ≥ 0} ∪ {bn a : n ≥ 1}. An nfa for L is given by the following transition graph: b b aλ a 2
  • 3. Problem 2: Linz 2.39 and 2.3.12 2.39: Let L be a regular language that does not contain λ. Show that there exists an nfa without λ-transitions and with a single final state that accept L. Since L is regular there exists a dfa, D = (Q, Σ, δ, q0, F), with an associated transition graph, GD, such that L(D) = L. We will construct an nfa N = (Q ∪ {qf }, Σ, δ , q0, {qf }) where qf /∈ Q by giving its transition graph GN as follows: 1. From GD, remove the final label from every final state (making them nonfinal states). 2. Add a new state qf and label it as a final state. 3. For every state qi, if there is a transition from qi to a state in F on input a ∈ Σ, then add a transition from qi to qf on input a. Clearly, N has a single accept state, qf , and no λ-transitions (since D is a dfa and we did not add any λ-transitions in our construction of N). We will now show that L(N) = L. First note that since λ /∈ L, every w ∈ L can be written as w = va for some v ∈ Σ∗ and an a ∈ Σ. Now, w = va ∈ L iff there is a walk on GD labeled with w from q0 to qi with qi ∈ F iff there is a walk on GD labeled with v from q0 to qj and a transition from qj to qi on input a iff there is a walk on GN labeled with v from q0 to qj and a transition from qj to qf on input a (since every transition in GD is a transition in GN and from step (3) in the construction of GN ) iff there is a walk on GN labeled with w from q0 to qf iff w ∈ L(N). Thus, w ∈ L iff w ∈ L(N). Therefore we conclude that L(N) = L and that for any regular language that does not contain λ, there exists an nfa without λ-transitions and with a single final state that accept L. 2.3.12: Show that if L is regular, so is LR . Since L is a regular language, we can construct a corresponding dfa, N, such that L(N) = L (For every regular language, there is a corresponding dfa, by definition, and for every dfa, there is an equivalent nfa). By definition, LR consists of all strings in language L in reverse order. We will construct a nfa, NR, representing LR such that L(NR) = LR. NR will contain an additional start state with λ-transitions to the final states of N. The direction of every transition in N is reversed. Also, the start state of N will be the final state of NR. The construction of nfa NR is as follows: Let N = (Q, Σ, δ, qn, F) NR = (Q ∪ {q0}, Σ, δr, qr, {qn}) Set of states of NR = set of states of N along with q0 = Q ∪ {qr} Σ = alphabet of NR = same as N qr = start state of NR {qn} = set of final states of NR = start state of N Transition function: δr(q, a) = {q1 : δ(q1, a) = q} δr(qr, λ) = F 3
  • 4. δr(qr, a) = ∅, if a = λ Now we will show that LR = L(NR). w ∈ LR iff wR ∈ L iff there is a walk on the transition graph of N with label wR from qn to some qi ∈ F iff there is a walk on the transition graph of NR from qr to qi with label λ and a walk from qi to qn with label w (Following the reverse of every transition in the original graph) iff w ∈ L(NR). Since LR can be represented by a nfa, it is regular (by equivalence of nfa to dfa, and dfa to regular language). Problem 3: Linz 2.1.8 2.1.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. For instance, the string abbbaab contains a run of b s of length three and a run of a s of length two. Find dfa’s for the following languages on {a, b}. (a): L = {w : w contains no runs of length less than four}. a b a aaaa a a a a a a b b b b b b b b b b b 4
  • 5. (b): L = {w : every run of a s has length either two or three}. b a b b bb aaaa (c): L = {w : there are at most two runs of a s of length three}. a a a a a a a a a a aaaa a a,b b b b b b b b b b b b b b b b b 5
  • 6. (d): L = {w : there are exactly two runs of a s of length 3}. b a a a a a aaa a a a a a a a a,b b b b b b b b b b b b b b b Problem 4: Linz 2.2.22 2.2.22: Let L be a regular language on some alphabet Σ, and let Σ1 ⊂ Σ be a smaller alphabet. Consider L1, the subset of L whose elements are made up only of symbols from Σ1, that is, L1 = L ∩ Σ∗ 1. Show that L1 is also regular. Since L is a regular language, there should be a dfa, N, representing L such that L(N) = L, where N = (Q, Σ, δ, q0, F). Since L1 is made up of strings with alphabets from Σ1, Σ1 ⊂ Σ, and L1 is a subset of L, L1 contains only strings that are accepted by L as well. We can construct a dfa, M, for L1 as follows: 1. From the transition graph of N, remove every transition that is labeled with some a /∈ Σ1. Now we will show that L(M) = L1. w = a1a2 . . . an ∈ L1 iff there is a walk on the transition graph of N with label w from q0 to some qi ∈ F and every ai ∈ Σ1 iff there is a walk on the transition graph of M from q0 to qi with label w (it will be the exact same path as it was in N) iff w ∈ L(M). Since L1 can be represented by a dfa, it is regular. 6
  • 7. Problem 5: Linz 2.3.3 and 2.3.8 2.3.3: Convert the following nfa into an equivalent dfa (see textbook for the diagram). 0 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 {0,1,2} {1,2}{0,1} {1} {2} Φ {0,2}{0} 2.3.8: Find an nfa without λ-transitions and with a single final state that accepts L = {a} ∪ {bn : n ≥ 1}. Noting that λ /∈ L, we can use the technique given in 2.3.9 (Problem 2) and we get the nfa given by the following transition graph: b b a b a,b 7