This presentation is the property of its rightful owner.
1 / 12

# Knuth-Morris-Pratt PowerPoint PPT Presentation

Knuth-Morris-Pratt. KMP algorithm. [over binary alphabet] Build DFA from pattern. Run DFA on text. Search Text. a. a. a. b. a. a. b. a. a. a. b. a. a. b. a. a. a. b. a. a. a. a. a. b. a. b. 0. 1. 3. 4. 2. 5. 6. accept state. b. b. b.

Knuth-Morris-Pratt

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

### Knuth-Morris-Pratt

• KMP algorithm. [over binary alphabet]

• Build DFA from pattern.

• Run DFA on text.

Search Text

a

a

a

b

a

a

b

a

a

a

b

a

a

b

a

a

a

b

a

a

a

a

a

b

a

b

0

1

3

4

2

5

6

accept state

b

b

b

### Knuth-Morris-Pratt

• KMP algorithm. [over binary alphabet]

• Build DFA from pattern.

• Run DFA on text.

Search Text

a

a

a

b

a

a

b

a

a

a

b

a

a

b

a

a

a

b

a

a

a

a

a

b

a

b

0

1

3

4

2

5

6

accept state

b

b

b

### Knuth-Morris-Pratt

• KMP algorithm. [over binary alphabet]

• Build DFA from pattern.

• Run DFA on text.

Search Text

a

a

a

b

a

a

b

a

a

a

b

a

a

b

a

a

a

b

a

a

a

a

a

b

a

b

0

1

3

4

2

5

6

accept state

b

b

b

### Knuth-Morris-Pratt

• KMP algorithm. [over binary alphabet]

• Build DFA from pattern.

• Run DFA on text.

Search Text

a

a

a

b

a

a

b

a

a

a

b

a

a

b

a

a

a

a

a

b

a

a

a

b

a

a

a

a

a

b

a

b

0

1

3

4

2

5

6

accept state

b

b

b

### Knuth-Morris-Pratt

• KMP algorithm. [over binary alphabet]

• Build DFA from pattern.

• Run DFA on text.

Search Text

a

a

a

b

a

a

b

a

a

a

b

a

a

b

a

a

a

a

a

b

a

a

a

b

a

a

a

a

a

b

a

b

0

1

3

4

2

5

6

accept state

b

b

b

### Knuth-Morris-Pratt

• KMP algorithm. [over binary alphabet]

• Build DFA from pattern.

• Run DFA on text.

Search Text

a

a

a

b

a

a

b

a

a

a

b

a

a

b

a

a

a

a

a

b

a

a

a

b

a

a

a

a

a

b

a

b

0

1

3

4

2

5

6

accept state

b

b

b

### Knuth-Morris-Pratt

• KMP algorithm. [over binary alphabet]

• Build DFA from pattern.

• Run DFA on text.

Search Text

a

a

a

b

a

a

b

a

a

a

b

a

a

b

a

a

a

a

a

b

a

a

a

b

a

a

a

a

a

b

a

b

0

1

3

4

2

5

6

accept state

b

b

b

### Knuth-Morris-Pratt

• KMP algorithm. [over binary alphabet]

• Build DFA from pattern.

• Run DFA on text.

Search Text

a

a

a

b

a

a

b

a

a

a

b

a

a

b

a

a

a

a

a

b

a

a

a

a

a

b

a

a

a

b

a

a

a

a

a

b

a

b

0

1

3

4

2

5

6

accept state

b

b

b

### Knuth-Morris-Pratt

• KMP algorithm. [over binary alphabet]

• Build DFA from pattern.

• Run DFA on text.

Search Text

a

a

a

b

a

a

b

a

a

a

b

a

a

b

a

a

a

a

a

b

a

a

a

a

a

b

a

a

a

b

a

a

a

a

a

b

a

b

0

1

3

4

2

5

6

accept state

b

b

b

### Knuth-Morris-Pratt

• KMP algorithm. [over binary alphabet]

• Build DFA from pattern.

• Run DFA on text.

Search Text

a

a

a

b

a

a

b

a

a

a

b

a

a

b

a

a

a

a

a

b

a

a

a

a

a

b

a

a

a

b

a

a

a

a

a

b

a

b

0

1

3

4

2

5

6

accept state

b

b

b

### Knuth-Morris-Pratt

• KMP algorithm. [over binary alphabet]

• Build DFA from pattern.

• Run DFA on text.

Search Text

a

a

a

b

a

a

b

a

a

a

b

a

a

b

a

a

a

a

a

b

a

a

a

a

a

b

a

a

a

b

a

a

a

a

a

b

a

b

0

1

3

4

2

5

6

accept state

b

b

b

### Knuth-Morris-Pratt

• KMP algorithm. [over binary alphabet]

• Build DFA from pattern.

• Run DFA on text.

Search Text

a

a

a

b

a

a

b

a

a

a

b

a

a

b

a

a

a

a

a

b

a

a

a

a

a

b

a

a

a

b

a

a

a

a

a

b

a

b

0

1

3

4

2

5

6

accept state

b

b

b