Você está na página 1de 3

12/21/13 dragon-book-exercise-answers/ch03/3.6/3.6.

md at master fool2fish/dragon-book-exercise-answers GitHub


https://github.com/fool2fish/dragon-book-exercise-answers/blob/master/ch03/3.6/3.6.md 1/3


fool2fish 8 months ago update 3.6.1
1 Contributor

Sign up Sign in
105 57
Star y Fork
fool2fish / Dragon-book-exercise-answers
PUBLIC

Q
+
@
y
y master branch: Dragon-book-exercise-answers / ch03 / 3.6 / 3.6.md _
_ File 188 lines (158 sloc) 3.094 KB
3.4 Figure 3-19 exercises to calculate the failure function KMP algorithm. Illustrated in the case of a known failure function, and how
according to the known keywords b_1b_2 ... b_n construct a DFA n +1 states with the DFA can identify the language. * B_1b_2 ...
b_n. Closer prove construct the DFA's time complexity is O (n).
For illustration, a string abbaabb 3.4.3-3 example, failure function is:
n: 1, 2, 3, 4, 5, 6, 7
f (n): 0, 0, 0, 1, 1, 2, 3
DFA was constructed as follows:
The DFA constructed pseudo-code:
for (i = 0; i <n; i + +) {
move [s [i], c] = {
if (c == b_1b_2 ... b_n [i]) {
goto s [i +1]
} Else {
goto s [f (i)]
}
}
}
Obviously, in a known f (n) of the case, the time complexity of the algorithm is O (n)
g Open Edit Raw Blame History Delete
3.6 Exercise
3.6.1!
Answer
Explore Features Enterprise Blog Search or type a command This repository
12/21/13 dragon-book-exercise-answers/ch03/3.6/3.6.md at master fool2fish/dragon-book-exercise-answers GitHub
https://github.com/fool2fish/dragon-book-exercise-answers/blob/master/ch03/3.6/3.6.md 2/3
3.3.5 for the exercise of each language to design a DFA or NFA.
NFA shown in Figure 3-29 to identify all labeled aabb path. The NFA accepts aabb it?
(0)-a-> (1)-a-> (2)-b-> (2)-b-> ((3))
(0)-a-> (0)-a-> (0)-b-> (0)-b-> (0)
(0)-a-> (0)-a-> (1)-b-> (1)-b-> (1)
(0)-a-> (1)-a-> (1)-b-> (1)-b-> (1)
(0)-a-> (1)-a-> (2)-b-> (2)-b-> (2)
(0)-a-> (1)-a-> (2)-b-> (2)--> (0)-b-> (0)
(0)-a-> (1)-a-> (2)--> (0)-b-> (0)-b-> (0)
The NFA apparently accepted aabb
For the NFA Figure 3-30, repeat the exercise 3.6.3
In practice is given below of the NFA conversion table:
1. Exercise 3.6.3
2. Exercise 3.6.4
3. Figure 3-26
Table 1
Status a b
0 {0,1} {0}
1 {1,2} {1}
2 {2} {2,3} {0}
3
Table 2
Status a b
0 {1} {3}
1 {2} {0}
2 {3} {1}
3 {0} {2}
3.6.2
3.6.3
Answer
3.6.4
3.6.5
Answer
12/21/13 dragon-book-exercise-answers/ch03/3.6/3.6.md at master fool2fish/dragon-book-exercise-answers GitHub
https://github.com/fool2fish/dragon-book-exercise-answers/blob/master/ch03/3.6/3.6.md 3/3
Table 3
Status a b
0 {1,2}
1 {2}
2 {2}
3 {4}
4 {4}
Status API Training Shop Blog About 2013 GitHub , Inc.. Terms Privacy Security Contact

Você também pode gostar