DFA Construction for KMP - PowerPoint PPT Presentation

About This Presentation
Title:

DFA Construction for KMP

Description:

DFA Construction for KMP. Reference: Chapter 19, Algorithms in C, 2nd Edition, Robert Sedgewick. ... DFA Construction for KMP: Implementation. Build DFA for KMP. ... – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 12
Provided by: kevin59
Category:
Tags: dfa | kmp | and | construction | the

less

Transcript and Presenter's Notes

Title: DFA Construction for KMP


1
DFA Construction for KMP
Reference Chapter 19, Algorithms in C, 2nd
Edition, Robert Sedgewick.
2
DFA Construction for KMP
Search Pattern
X
pattern1..j
j
next
a
a
b
a
a
a
b
b
a
b
0
3
DFA Construction for KMP
Search Pattern
X
pattern1..j
j
next
a
a
b
a
a
a
b
b
0
0
0
0
a
1
b
0
b
a
0
1
4
DFA Construction for KMP
Search Pattern
X
pattern1..j
j
next
a
a
b
a
a
a
b
b
0
0
0
a
1
1
0
0
1
a
1
2
b
0
0
b
a
a
0
1
2
b
5
DFA Construction for KMP
Search Pattern
X
pattern1..j
j
next
a
a
b
a
a
a
b
b
0
0
0
a
1
1
0
a
b
0
2
2
0
1
2
a
1
2
2
b
0
0
3
a
b
a
a
b
3
0
1
2
b
6
DFA Construction for KMP
Search Pattern
X
pattern1..j
j
next
a
a
b
a
a
a
b
b
0
0
0
a
1
1
0
a
b
0
2
2
0
1
2
3
a
b
a
1
3
0
a
1
2
2
4
b
0
0
3
0
a
b
a
a
a
b
3
4
0
1
2
b
b
7
DFA Construction for KMP
Search Pattern
X
pattern1..j
j
next
a
a
b
a
a
a
b
b
0
0
0
a
1
1
0
a
b
0
2
2
0
1
2
3
4
a
b
a
1
3
0
a
1
2
2
4
5
a
b
a
a
2
4
0
b
0
0
3
0
0
b
a
b
a
a
a
a
b
3
4
5
0
1
2
b
b
8
DFA Construction for KMP
Search Pattern
X
pattern1..j
j
next
a
a
b
a
a
a
b
b
0
0
0
a
1
1
0
a
b
0
2
2
0
1
2
3
4
5
a
b
a
1
3
0
a
1
2
2
4
5
6
a
b
a
a
2
4
0
b
0
0
3
0
0
3
a
b
a
a
a
2
5
3
b
a
b
a
a
a
a
a
b
3
4
5
6
0
1
2
b
b
b
9
DFA Construction for KMP
Search Pattern
X
pattern1..j
j
next
a
a
b
a
a
a
b
b
0
0
0
a
1
1
0
a
b
0
2
2
0
1
2
3
4
5
6
a
b
a
1
3
0
a
1
2
2
4
5
6
2
a
b
a
a
2
4
0
b
0
0
3
0
0
3
7
a
b
a
a
a
2
5
3
a
b
a
a
a
b
3
6
2
b
a
b
a
a
a
a
a
b
b
3
4
5
6
0
1
2
7
b
b
b
a
10
DFA Construction for KMP
X
Search Pattern
pattern1..j
j
next
0
0
a
a
b
a
a
a
b
b
0
a
1
1
0
a
b
0
2
2
0
1
2
3
4
5
6
7
a
b
a
1
3
0
a
1
2
2
4
5
6
2
4
a
b
a
a
2
4
0
b
0
0
3
0
0
3
7
8
a
b
a
a
a
2
5
3
a
b
a
a
a
b
3
6
2
a
b
a
a
a
b
b
0
7
4
11
DFA Construction for KMP Implementation
  • Build DFA for KMP.
  • Takes O(M) time.
  • Requires O(M) extra space to store next table.

int X 0 int next new intM for (int j
1 j lt M j) if (p.charAt(X)
p.charAt(j)) // char match nextj
nextX X X 1 else
// char mismatch nextj
X 1 X nextX
DFA Construction for KMP (assumes binary alphabet)
Write a Comment
User Comments (0)
About PowerShow.com