Substrings

http://en.wikipedia.org/wiki/Substring_search

AlgorithmPreprocessing timeMatching time1
Naïve string search algorithm0 (no preprocessing)Θ((n−m+1) m)
Rabin–Karp string search algorithmΘ(m)average Θ(n+m),
worst Θ((n−m+1) m)
Finite-state automaton based searchΘ(m |Σ|)Θ(n)
Knuth–Morris–Pratt algorithmΘ(m)Θ(n)
Boyer–Moore string search algorithmΘ(m + |Σ|)Ω(n/m), O(nm)
Bitap algorithm (shift-orshift-andBaeza–Yates–Gonnet)Θ(m + |Σ|)O(mn)

Rabin–Karp string search algorithm
Rolling hash.

No comments:

Post a Comment