Edit page

Boyer Moore

Boyer–Moore string-search algorithm is an efficient string-searching algorithm that is the standard benchmark for practical string-search literature. It was developed by Robert S. Boyer and J Strother Moore in 1977. The algorithm preprocesses the string being searched for (the pattern), but not the string being searched in (the text). It is thus well-suited for applications in which the pattern is much shorter than the text or where it persists across multiple searches. The Boyer–Moore algorithm uses information gathered during the preprocess step to skip sections of the text, resulting in a lower constant factor than many other string search algorithms. In general, the algorithm runs faster as the pattern length increases. The key features of the algorithm are to match on the tail of the pattern rather than the head, and to skip along the text in jumps of multiple characters rather than searching every single character in the text. (Source: Wikipedia)

Complexity

NamePreprocessingAverageWorstSpaceComments
Boyer Moorem + kn/mn * mk

* Where n = length of the source; m = length of the query pattern; k = size of the Alphabet

References

  • Geeksforgeeks
  • Wikipedia
  • YouTube