Presentation is loading. Please wait.

Presentation is loading. Please wait.

String Matching Chapter 32 Highlights Charles Tappert Seidenberg School of CSIS, Pace University.

Similar presentations


Presentation on theme: "String Matching Chapter 32 Highlights Charles Tappert Seidenberg School of CSIS, Pace University."— Presentation transcript:

1 String Matching Chapter 32 Highlights Charles Tappert Seidenberg School of CSIS, Pace University

2 String Matching Problem in this chapter Problem: Find all valid shifts s with which a given pattern P occurs in a given text T This problem occurs in text editing, DNA sequence searches, and Internet search engines Example:

3 String Matching Algorithms Preprocessing & Matching Times

4 Notation and Terminology (Sigma-star) = set of all finite-length strings of alphabet sigma (eta is empty string) String w is a prefix of string x, denoted w [ x, if x = wy for some string y String w is a suffix of string x, denoted w ] x, if x = yw for some string y Example: ab [ abcca and cca ] abcca

5 Problem Re-statement in notation/terminology Denote a k-char prefix P[1..k] of pattern P by P k Similarly, denote a k-char prefix of text T by T k Matching problem: Given n = T.length and m = P.length, find all shifts s in range 0<=s<=n-m such that P ] T s+m

6 Naïve String Match Algorithm sliding “template” pattern match

7 Problem 1-1 How many template comparisons are made? How many were matches and how many non-matches? How many computation units are used? Problem 1-2 How many computation units are used? Naïve String Match Algorithm sliding “template” pattern match

8 Finite Automata Algorithm Efficient – examine each text char only once

9 Finite Automata Algorithm Example: simple two-state finite automaton: Transition function (delta) State transition diagram

10 Finite Automata Algorithm Final-state function Final-state function (phi)

11 Finite Automata Algorithm Construct the automaton Suffix function (small sigma)

12 Finite Automata Algorithm Construct the automaton Example: State m P = a b a b a c a

13 Finite Automata Algorithm Critical transition function (delta) Transition function (delta) obtained from Suffix function (small sigma)

14 Finite Automata Algorithm Matching operation Transition function (delta)

15 Finite Automata Algorithm Compute transition function Transition function (delta)

16 Finite Automata Algorithm Problem 3-1 Problem 3-2


Download ppt "String Matching Chapter 32 Highlights Charles Tappert Seidenberg School of CSIS, Pace University."

Similar presentations


Ads by Google