Presentation is loading. Please wait.

Presentation is loading. Please wait.

Examples for Finite Automata

Similar presentations


Presentation on theme: "Examples for Finite Automata"— Presentation transcript:

1 Examples for Finite Automata
CSC3130 Tutorial One Bridge Zhao Department of Computer Science & Engineering

2 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 q1 1 q2 q3 1 q0 start q4 1 absorbing state dead state CSC3130 Tutorial One 9/22/2018

3 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”. 1 q0 start q1 1 q2 q3 1 1 CSC3130 Tutorial One 9/22/2018

4 NFA for Common Suffix We can have a simpler representation for common suffix language using NFA: Use subset construction to convert it to a DFA. q0 1,0 q1 1 q2 q3 1 start compare with previous DFA 1 q0 start q0q1 1 q0q2 q0q1q3 1 1 CSC3130 Tutorial One 9/22/2018

5 NFA Example Construct NFA for the language over the alphabet {a, b, …, z} such that every string doesn’t contain “fool”. ‘f’ dead state not ‘f’ ‘f’ ‘f’ q1 ‘f’ ‘o’ q2 q3 ‘l’ start q0 q2 ‘o’ not ‘f’,‘l’ not ‘f’,‘o’ not ‘f’,‘o’ CSC3130 Tutorial One 9/22/2018

6 State Upper Bound By subset construction, an NFA with n states can be expressed by a DFA with no more than 2n states. Is this upper bound tight? b δ(i, a)={i+1}, (0<i<n) δ(i, b)={i+1}, (1<i<n) δ(1, b)={1} δ(n, b)=Ø δ(n, a)={1, 2} 1 start a a n i 2 3 a,b CSC3130 Tutorial One 9/22/2018

7 the DFA has 16=24 states in total
n=4 Case a 2 a 3 a 4 b Ø 1 start a 1,2 a 1,2,4 a 3,4 a 2,3 b 1,3 a 1,2,3,4 a 2,3,4 a 1,2,3 a 2,4 b 1,3,4 b 1,4 δ(i, a)={i+1}, (i=1,2,3) δ(i, b)={i+1}, (i=2,3) δ(1, b)={1} δ(4, b)=Ø δ(4, a)={1, 2} the DFA has 16=24 states in total upper bound is tight CSC3130 Tutorial One 9/22/2018

8 Regular Expressions Construct a RE over d={0,1} such that
It contains all strings that have two consecutive “0”s. It contains all strings except those with two consecutive “0”s. It contains all strings with an even number of “0”s. CSC3130 Tutorial One 9/22/2018

9 Tips for RE Construction
(1+0)*00(1+0*) We can divide the string into segments: Use similar idea as 2: ((1*0)(1*0))*1* (ε +0) (11*0)* 1* CSC3130 Tutorial One 9/22/2018


Download ppt "Examples for Finite Automata"

Similar presentations


Ads by Google