Examples For Finite Automata: CSC3130 Tutorial One

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 12

Fall 2009

Examples for Finite Automata


CSC3130 Tutorial One
Xiao Linfu
lfxiao@cse.cuhk.edu.hk

Department of Computer Science &


Engineering

Outline
DFA example
NFA example
NFA to DFA conversion
Regular Expressions

DFA
For every string x, there is a unique path
from initial state and associated with x.
x

x is accepted if and only if this path ends at


a accept state.

NFA
For any string x, there may exist none or
more than one path from initial state
and associated with x.
x is accepted if there is some path that
ends at a accept state.

Strings With Common Prefix


Construct a DFA that accepts a language L
over = {0, 1} such that L is the set of all
strings starting with 101.
0,1

star
t

q0

q1
1

q2

q4
0,1

dea
d
stat
e

q3
absorbi
ng state

Strings With Common Suffix


Construct a DFA that accepts a language L
over = {0, 1} such that L is the set of all
strings ending with 101.
0
0

star
t

q0

1
1

q1

q10
1

0
1

q101

NFA for Common Suffix


We can have a simpler representation for
common suffix language using NFA:
1,0

star
t

q0

q1

q2

q3

Use subset construction to convert it to a


DFA.
0
0

star
t

q0

1
1

q0q1

q0q2
1

0
1

q0q1q3
compare with
previous DFA

NFA Example
Construct NFAs for the following languages
over the alphabet {a, b, , z}:
All strings that contain eat or sea or easy
all

star
t

q1

q0

q2
s

q3
y

q4

s
e

q5

all

q6

NFA Example
Construct NFA for the language over the
alphabet {a, b, , z} such that every string
doesnt contain fool.
not
f

star
t

q0

f
f

q1

not
f,o
not f,o

q2

q2

not f,l

dea
d
stat
e

q3

Regular Expressions
- Alphabet X = {a, b, c, d}
1) (a + b)*
all strings containing only a and b
2) c(a + b + c)*c2
all strings containing only a, b, and c that begin with c and
end with cc
3) all strings containing only one b
(a+c+d)*b(a+c+d)*

Regular Expressions
- Alphabet X = {0, 1}
1) (0 + 1)*
the set of all binary strings
2) 031*04
all strings consisting of three 0s, followed by any number
of 1s, followed by four 0s
3) 0*1001*
all strings starting with any number of 0s, followed by
100, followed by and number of 1s

Thank you!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy