You are on page 1of 20

EXAM PREPARATION

Theory Lecture 17
of DFA Important
Automata Examples and
Solutions
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa that accept exactly a Q: Draw fa that accepts all words


starting with a
a
R=a q0 q1 R = a(a+b)*

a,b a, b
b a, b a q1
q0

q2 a, b
b
q2

q0: Initial State q0: Initial State


q1: final State q1: final State
q2: Dead State (Dead End State) q2: Dead State (Dead End State)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa that accepts exactly a or b


Comma , = OR
R = a+b
a
a,b
q0 q1 q0 q1

a,b a,b
b
a, b
a, b
q2
q2

q0: Initial State q0: Initial State


q1: final State (accepting state) q1: final State
q2: Dead State (Dead End State / trap / rejecting) q2: Dead State (Dead End State)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa for the language that have b as a second letter over ∑ = { a , b }

R = (a+b)b(a+b)*
a,b
a,b b
q0 q2
ab q1

bb a
abaa
bbaa q3 a, b
abaababa
q0: Initial State
q2: final State (accepting state)
q3: Dead State (Dead End State / trap / rejecting)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa for the language that have exactly 4 ones in every string over
∑={0,1}

R = 0* 1 0* 1 0* 1 0* 1 0*
0 0 0 0 0
1 1 1 1
q0 q1 q2 q3 q4
1111
01111
1
011110
010101010
q5 0, 1
q0: Initial State
q4: final State (accepting state)
q5: Dead State (Dead End State / trap / rejecting)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa for the language that only accept L = {01, 011 , 100} over
∑={0,1}

R = 01 + 011 + 100
0 1
q0 q1 q2

0 0
1 1
0 0
q7 q6 q5 1
1
0, 1
q0: Initial State 0, 1
q4 q3
q2, q3, q7: final State 0, 1
q4: Dead State (Dead End State)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Draw fa for the language L = { w.na = 1 w ε (a,b)* }

R= b* a b*
b b
a a
q0 q1
ab
ba a
bab
bbbabbb
a, b
q2

q0: Initial State


q1: final State
q2: Dead State (Dead End State)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: L = { w ∈ {0, 1}* | w contains 00 as a substring }

R= (0+1)* 00 (0+1)*

1 0,1
00 0 0
100 q0 q1 q2

1001 1
101001
010001
11100111 q0: Initial State
q2: final State (Accepting State)
10001
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa that accept all strings with double aa in somewhere over ∑ = {a, b}

R= (a+b)* aa (a+b)* R= (0+1)* 00 (0+1)*

aa b a,b
baa a a
q0 q1 q2
baab
b
babaab
abaaab
bbbaabbb
q0: Initial State
baaab q2: final State (Accepting State)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa that contains exactly baa

R = baa

b a a
q0 q1 q2 q3

b b
a a, b

q4 a, b

q0: Initial State


q3: final State (Accepting State)
q4: Dead State (Dead End State/Trap/Rejecting)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa that accept exactly baa and ab

R = baa + ab

b a b a a
q6 q5 q0 q1 q2 q3

a b b
a, b a, b

q4 a, b

q0: Initial State


q3, q6: final State (Accepting State)
q4: Dead State (Dead End State/Trap/Rejecting)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa starting with a and contains any number of b’s in end

R = ab* b
a
q0 q1

a
b a, b
q2

q0: Initial State


q1: final State (Accepting State)
q2: Dead State (Dead End State/Trap/Rejecting)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa accept all words ending with a


a
R = (a+b)*a aa
b a aaa
a ba
q0 q1 baa
bbaa
b aba
abba
babbaa
q0: Initial State
q1: final State (Accepting State)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa that accept all words starting and ending with a over ∑= {a , b}

R = a(a+b)*a

b a
a
q0 a q1 q2

b
q0: Initial State b a, b
q2: final State q3
q3: Dead End State
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Construct an FA which recognizes the set of all strings defined


over S = {x, y} starting with the prefix ‘xy’.

R = xy(x+y)* x,y

q0
x
q1
y xyxx
q3
xyyyy
x
xyxxyy
y x, y
q2
yx
q0: Initial State xx
q3: Final State (Accepting State)
q2: Dead State (Dead End State/Trap State/Rejecting State)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa that accept all strings with even length over ∑ = { a , b }

R = ( aa + ab + ba + bb )*

a, b
q0 q1

a, b

q0: Initial State


q1: Final State (Accepting State)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa that accept all strings with even no of b’s over ∑ = { a , b }

R = a* + ( a* ba* ba*)*
a a
b
bb q0 q1
aaaa
baba b
bbaa

q0: Initial State


q1: Final State (Accepting State)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa that accept all strings with odd no of 1’s over ∑ = { 0 , 1 }

R = 0*10* (10*10*)*
0 0
1
q0 q1

q0: Initial State


q1: Final State (Accepting State)
Lecture 17: DFA Important Examples and Solutions alisoomro666@gmail.com

Q: Draw fa that accept all words ending with ab over ∑ = { a , b }


R = (a+b)*ab
b a

a b
q0 q1 q2
abab
a
abbab
b

q0: Initial State


q2: Final State (Accepting State)
Download Exam Preparation Material From
www.automataexam.blogspot.com

Theory Buy Laptops & Mobiles 70% Discounts


www.amazon.com/shop/programology

of Thank you 
Subscribe
Automata
By: Ali Hassan Soomro
BSCS from UBIT, University of Karachi
DAE in Electronics from SBTE
Facebook: www.facebook.com/AliiHassanSoomro
Gmail: alisoomro666@gmail.com

You might also like