Академический Документы
Профессиональный Документы
Культура Документы
Table 1: Accepted strings of 3 or less. (c) (2 points) Convert the automaton to a DFA. state q0 q1 q2 a {p,q,r} {p,q,r} b {q,r} {r} c {p,q,r} {p,q,r}
Table 2: DFA Version of given -NFA. a,c b a,c Figure 1: Graphical representation of table 2. b
start
q0
q1
q2
2. (4 points) Design -NFA that accepts the set of strings consisting of either 01 repeated one or more times or 010 repeated one or more times. Try to use -transitions to simplify your design. q1 0 0 start q0 q3 1 q2
Figure 2: Graphical representation of table of the -NFA with inclusive or interpretation. This accepts any string that has 01s and 010s in it, but it can have both.
q1
q2
1 0
q6
start
q0
q3
q4
q5 0
q7
Figure 3: Graphical representation of table of the -NFA with exclusive or interpretation. This accepts any string that has 01s or 010s in it, but once it determines which pattern it follows, it cant deviate. 3. (6 points) Write regular expressions for each of the following languages. (a) (3 points) The set of strings of 0s and 1s with at most one pair of consecutive 1s. (0*10*)*( + 11 + 1)(0*10*)* (b) (3 points) The set of strings of as and bs that contain at lesat two bs that are not followed by an a. (a*b*)*(bb(b + a(a*b*)*bb))(a*b*)* 4. (4 points) Convert the following regular expressions to NFAs with transitions. 2
start
q0 1 q2
q1
q3
q4
q5
start
q0
q1
0 q2 q3
0,1 Figure 5: -NFA version of 00(0+1)* 5. (6 points) GNU Emacs supports ... (a) (3 points) Give a search-and-replace command to change ... Use the command: ]\[ to nd each instance and replace it with ,. (b) (3 points) Emacs employs several extensions ... i. Given a le in which each line is a name in the form Lastname, Firstname change it so that the names appear as Firstname Lastname. Use reg-exp: \([A-Za-z][A-Za-z]*\)\(,\) \([A-Za-z][A-Za-z]*\) Replace with: \3 \1 ii. Swap the rst and third aguments in all calls to the function foo... Use reg-exp: \