Skip to content

Commit bb6fa74

Browse files
authored
Update rabin-karp explanation
1 parent b28fdd6 commit bb6fa74

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/string/rabin-karp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Problem: Given two strings - a length $m$ pattern to find in a length $n$ text,
1313

1414
The naive solution is to simply check all length $m$ substrings in the $n$ length text, but that would take $\Theta(mn)$ time.
1515

16-
The algorithm uses the concept of a "rolling hash", in which we compute a hash for the pattern and another for the first substring in $\Theta(m)$ time, but then use a special hash function that lets us go from one to the next in constant time.
16+
The algorithm uses the concept of a "rolling hash", in which we compute a hash for the pattern and another for the first substring in $\Theta(m)$ time, but then use a special hash function that lets us go from one to the next in constant time. We compare the hash to our known hash of the pattern, and if they are the same then we likely have a match.
1717

1818
## The hash function
1919

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy