Rabin–Karp algorithm: Difference between revisions

Content deleted Content added
Watcher (talk | contribs)
big article about Rabin-Karp string search algorithm
 
Watcher (talk | contribs)
m =Shifting substrings search and competing algorithms=
Line 2:
 
== Shifting substrings search and competing algorithms ==
The basic problem the algorithm addresses is finding a pattern (fixed substring) of length m within a text of length n, for example "sun" in "Hello sunshine in this vale of tears." By way of comparison of the algorithms, a naive brute force string searching algorithm involves aligning the first character of the pattern with the first character of the text and checking if the pattern matches the initial substring of equivalent length. If it does not match, the pattern is shifted right by 1 and the procedure is repeated, for a worst case running time of m*n. [[Knuth-Morris-Pratt- algorithm]] is an elegant elaboration on this naive algorithm that uses precomputed data to skip forward not by 1 character, but by as many as possible for the search to succeed.
 
== Use of hashing for shifting substring search ==