Midterm 1 Prctice CS 350 Fll 2018 gilry.org/clsses/fll2018/cs350/ 1
Midterm #1: Thursdy, Septemer 27! Bring less stuff, if possile. Keep ny gs under the tle. You my hve out: pencil, pen, nd/or erser. My hve wter. No pper. You ll e provided scrtch pper if you need it. You ll hve 75 minutes: the test is from 12:30 1:45p.!2
Tody: review prolems nd solutions!3
0) L is the lnguge L(). Digrm its NFA using the stndrd construction we ve seen:!4
0) L is the lnguge L(). Digrm its NFA using the stndrd construction we ve seen: q1 q2!5
1) L is the lnguge L(*). Digrm its NFA using the stndrd construction. (It s crucil to use the generl process nd not design n NFA d hoc!)!6
1) L is the lnguge L(*). Digrm its NFA using the stndrd construction. (It s crucil to use the generl process nd not design n NFA d hoc!) q1 q2 q4 q5 q6!7
2) L is the lnguge L( *). Digrm its NFA using the stndrd construction.!8
2) L is the lnguge L( *). Digrm its NFA using the stndrd construction. q1 q4 q6 q2 q5 q7 q8!9
So to rek this down, this prt is: q1 q4 q6 q2 q5 q7 q8!10
So to rek this down, this prt is: * q1 q4 q6 q2 q5 q7 q8!11
So to rek this down, this prt is: * q1 q4 q6 q2 q5 q7 q8!12
So to rek this down, this is: * q1 q4 q6 q2 q5 q7 q8!13
3) L is the lnguge L(0(1 10)). Digrm its NFA using the stndrd construction.!14
3) L is the lnguge L(0(1 10)). Digrm its NFA using the stndrd construction. 0 q1 1 q6 q2 q9 1 0 q4 q5 q7 q8!15
4) Find regex equivlent to: x q1 y y y x q2!16
4) Find regex equivlent to: x q1 yy y x!17
4) Find regex equivlent to: xy yy x!18
4) Find regex equivlent to: xy yy x* q 3!19
4) Find regex equivlent to: So vlid regex is: (xy yy)x*!20
5) Find regex equivlent to: x q1 y y y q2!21
5) Find regex equivlent to: x q1 yy y!22
5) Find regex equivlent to: yy x q1 y!23
5) Find regex equivlent to: yy y(yy)*x x q1 So vlid regex is: (yy)*x(y(yy)*x)*!24
6) Find DFA nd regex tht represents the intersection of L(( )*) nd L(( )*)!25
6) Find DFA nd regex tht represents the intersection of L(( )*) nd L(( )*) Hint: L(( )*) L(( )*) q2 q1 q1!26
Ech stte is in Q0xQ1 nd only (,) ccepts ecuse oth nd ccept:,,q1 q1 L(( )*) q1,q2 q1,,q2 q2 So: L(( )*) L(( )*) q1 L(( )*) = L(()*) Mkes sense!!27
7) Digrm DFA tht represents strings either not in L(( )*) or not in L(( )*)!28
So, y De Morgn s lws, L 0 L 1 = (L 0 L 1 ), we wnt the complement of this sme DFA:,,q1 q1,,q2!29
So, we dd n explicit ded stte: q1 q2, ded!30
nd invert the set of ccept sttes F, with respect to the overll set of sttes Q (Q-F) q1 q2, live!31
8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: But first, reminder!!32
The ε-closure of set of sttes is the set of sttes which re rechle without consuming ny chrcters/strings. (Another fixpoint itertion.) closure δ : P(Q) P(Q) closure δ (qs) = ext N δ (qs) where ext N 1 (qs) = ext δ N δ (qs) ext δ (qs) = qs {q q qs (q,, q ) δ}!33
The move of set of sttes nd chrcter s, is the set of sttes which re rechle from ny input stte, vi single trnsition on the chrcter s. move δ : P(Q) Σ P(Q) move δ (qs, s) = {q q qs (q, s, q ) δ}!34
The suset lgorithm Input: NFA (Q, Σ, δq,, FQ) Output: DFA (D, Σ, δd, d0, FD) Let d0 = ε-closureδ({}) mrked = {} D = {d0} δd = {} While d D such tht d mrked: mrked = mrked {d} For ech s Σ: Let dmv = moveδ(d,s) Let dmv+ε = ε-closureδ(dmv) If dmv+ε D: D = D {dmv+ε} δd = δd {(d,s,dmv+ε)} FD = { d D q d. q FQ}!35
8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm:!36
8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 q2 q4!37
8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA Strt t ε-closure({}) d0 = {,q1,q2} q1 q2 q4 d0 DFA!38
8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 Strt t ε-closure({}) d0 = {,q1,q2} d1 = ε-clo(moveδ(d0,)) = {,,q1,q2} q2 q4 d0 d1 DFA!39
8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 Strt t ε-closure({}) d0 = {,q1,q2} d1 = {,,q1,q2} d2 = ε-clo(moveδ(d0,)) = {q4} q2 q4 d0 d1 d2 DFA!40
8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 Strt t ε-closure({}) d0 = {,q1,q2} d1 = {,,q1,q2} d2 = {q4} d1 = ε-clo(moveδ(d1,)) q2 q4 d0 d1 d2 DFA!41
8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 Strt t ε-closure({}) d0 = {,q1,q2} d1 = {,,q1,q2} d2 = {q4} d2 = ε-clo(moveδ(d1,)) q2 q4 d0 d1 d2 DFA!42
8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 Strt t ε-closure({}) d0 = {,q1,q2} d1 = {,,q1,q2} d2 = {q4} = ε-clo(moveδ(d2,)) Ø q2 q4 d0 d1 d2 DFA!43
8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 Strt t ε-closure({}) d0 = {,q1,q2} d1 = {,,q1,q2} d2 = {q4} = ε-clo(moveδ(d2,)) Ø q2 q4 d0 d1 d2 DFA!44
8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 Strt t ε-closure({}) d0 = {,q1,q2} d1 = {,,q1,q2} d2 = {q4} q2 q4 d0 d1 d2 DFA!45
9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm:!46
9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 q9 q10!47
9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 q9 q10 d0!48
9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 q9 q10 d0 d1!49
9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 d2 q9 q10 d0 d1!50
9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 d2 q9 q10 d0 d1 d3!51
9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 d2 q9 q10 d0 d1 d4 d3!52
9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 d0 d1 d2 d4 q9 q10 d3!53
9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 d0 d1 d2 d4 q9 q10 d3!54
Other prolems we should work out? Any prolems from the prctice exm?!55