



















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




















Compiler
Compiler
Construction
Construction
Compiler
Compiler
Construction
Construction
Lecture 5
DFA and NFA
DFA and NFA DFA and NFA
DFA and NFA
Deterministic Finite Automata (DFA)
One transition per input per state.
No - moves
NFA vs DFA
NFA vs DFA NFA vs DFA
NFA vs DFA
NFAs and DFAs recognize the same set of
languages (regular languages)
DFAs are easier to implement – table driven.
NFA vs DFA
NFA vs DFA NFA vs DFA
NFA vs DFA
For a given language, the NFA can
be simpler than the DFA.
DFA can be exponentially larger
than NFA.
Construction
Construction
Construction
Construction
The algorithm for RE to DFA conversion is
called Thompson’s construction
Build an NFA for each RE term.
Combine NFAs with e -moves.
NFA Construction
NFA Construction
RE
NFA Construction
NFA Construction
Subset construction
NFA → DFA
Build the simulation or model.
Minimize number of states in DFA
( Hopcroft’s algorithm )
NFA Construction
NFA Construction RE
NFA Construction
NFA Construction
s
0
a
s
1
NFA for a
s
0
a
s
1
NFA for ab
s
3
b
s
4
NFA Construction
NFA Construction RE
NFA Construction
NFA Construction
s
0
a
s
1
NFA for a
NFA Construction
NFA Construction RE
NFA Construction
NFA Construction
s
0
a
s
1
NFA for a
s
0
a
s
1
s
3
b
s
4
s
3
b
s
4
NFA for b
NFA Construction
NFA Construction RE
NFA Construction
NFA Construction
s
0
a
s
1
NFA for a
s
0
a
s
1
NFA for ab
s
3
b
s
4
s
3
b
s
4
NFA for b
NFA Construction
NFA Construction RE
NFA Construction
NFA Construction
s
1
a
s
2
NFA for a
NFA Construction
NFA Construction RE
NFA Construction
NFA Construction
s
1
a
s
2
s
3
b
s
4
NFA for a and b
NFA Construction
NFA Construction RE
NFA Construction
NFA Construction
s
0
s
4
s
1
a
s
2
NFA for a*
NFA Construction
NFA Construction RE
NFA Construction
NFA Construction
s
1
a
s
2
NFA for a