Abstract

String matching is the problem of finding all occurrences of a string …[0… m - 1] of length m called a pattern, in a longer string …[0… n - 1] of length n called a text. Several string matching algorithms have been designed to solve the problem in linear time; most of them work in two steps, called pattern preprocessing and text search step. The paper addresses the definition and computation of the shift function in the pattern preprocessing step of on-line string matching algorithms. The shift function depends essentially on the order the pattern characters are compared with the corresponding text characters. We consider a family … of algorithms that do not change the character comparison order J during execution and we present a uniform definition of shift function δ J for such algorithms via a function imin J . The definition allows one to compute δ J in O( m log log m) time in the worst case, given imin J , but sufficient conditions to compute δ J in O( m) time are provided. Computing imin J requires O( m 2) comparisons in general. We introduce the class of compact orders (which is the generalization of Knuth-Morris-Pratt, Boyer-Moore and Crochemore-Perrin character comparison orders) and we give algorithms to compute both function imin J and shift function δ J in O( m) time for all compact orders. We show that given the order J and the pattern … there exists a set C of equivalent orders such that the function imin K can be computed in linear time given imin J for all orders K ϵ C. Moreover, we characterize two orders in the set C that respectively minimize and maximize the values of the shift function and we show that for both those orders the shift function can be computed in linear time given imin J .

Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call