On Boyer-Moore Preprocessing

Heikki Hyyrö · Tampere University Institutional Repository (Tampere University) · 2004

Probably the two best-known exact string matching algorithms are the linear-time algorithm of Knuth, Morris and Pratt (KMP), and the fast on average algorithm of Boyer and Moore (BM).The efficiency of these algorithms is based on using a suitable failure function.When a mismatch occurs in the currently inspected text position, the purpose of a failure function is to tell how many positions the pattern can be shifted forwards in the text without skipping over any occurrences.The BM algorithm uses two failure functions: one is based on a bad character rule, and the other on a good suffix rule.The classic linear-time preprocessing algorithm for the good suffix rule has been viewed as somewhat obscure [8].A formal proof of the correctness of that algorithm was given recently by Stomp [14].That proof is based on linear time temporal logic, and is fairly technical and a-posteriori in nature.In this paper we present a constructive and somewhat simpler discussion about the correctness of the classic preprocessing algorithm for the good suffix rule.We also highlight the close relationship between this preprocessing algorithm and the exact string matching algorithm of Morris and Pratt (a pre-version of KMP).For these reasons we believe that the present paper gives a better understanding of the ideas behind the preprocessing algorithm than the proof by Stomp.This paper is based on [9], and thus the discussion is originally roughly as old as the proof by Stomp.

Read the paper · More papers on PaperTik