next up previous
Next: String Matching Up: CSE 2320: Algorithms and Previous: CSE 2320: Algorithms and

String Matching



Find all occurrences of a pattern in a text



String Matching Problem:

Given text array T[1..n] and pattern array P[1..m] of characters from alphabet $\Sigma$, find all s such that T[s+1..s+m] = P[1..m], i.e., P occurs with shift s in T.

Example

r o w   r o w   r o w   y o u r   b o a t
                    P = y o              

s = 12

$\Sigma$ = {a, b, o, r, t, u, w, y}



T: yoyoyoyo
P: yoyo


next up previous
Next: String Matching Up: CSE 2320: Algorithms and Previous: CSE 2320: Algorithms and
Copyright © 1998 The University of Texas at Arlington