Content deleted Content added
m Accuracy |
→External links -> References: Add bibliographical information |
||
Line 77:
Other algorithms can search for a single pattern in time order O(n), hence they will search for k patterns in time order O(n*k). The variant Rabin-Karp above will still work in time order O(n) in the best and average case, because a hash table allows to check whether or not substring hash equals any of the pattern hashes in time order of O(1). We can also ensure O(''mn''log ''k'') time in the worst case, where ''m'' is the length of the longest of the ''k'' strings, by storing the hashes in a [[self-balancing binary search tree]] instead of a hash table.
==
* Karp and Rabin's original paper: Karp, Richard M.; Rabin, Michael O. (March 1987). "[http://www.research.ibm.com/journal/rd/312/ibmrd3102P.pdf
[[Category:Algorithms on strings]]
|