![]() |
TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
The Rabin-Karp Algorithm for finding a pattern within a piece of text with complexity O(n + m) More...
#include <cassert>#include <cmath>#include <iostream>#include <cstring>Go to the source code of this file.
Namespaces | |
| namespace | string_search |
| String search algorithms. | |
Macros | |
| #define | PRIME 5 |
| Prime modulus for hash functions. | |
Functions | |
| int64_t | string_search::create_hash (const std::string &s, int n) |
| int64_t | string_search::recalculate_hash (const std::string &s, int old_index, int new_index, int64_t old_hash, int patLength) |
| bool | string_search::check_if_equal (const std::string &str1, const std::string &str2, int start1, int end1, int start2, int end2) |
| int | string_search::rabin_karp (const std::string &str, const std::string &pat) |
| int | main (void) |
| int | rabin_karp (const std::string &str, const std::string &pat) |
The Rabin-Karp Algorithm for finding a pattern within a piece of text with complexity O(n + m)
Definition in file rabin_karp.cpp.
| #define PRIME 5 |
Prime modulus for hash functions.
Definition at line 16 of file rabin_karp.cpp.
| int main | ( | void | ) |
Main function
Definition at line 105 of file rabin_karp.cpp.
| int string_search::rabin_karp | ( | const std::string & | str, |
| const std::string & | pat ) |
Perform string pattern search using Rabin-Karp algorithm
| [in] | str | string to search in |
| [in] | pat | pattern to search for |
Definition at line 83 of file rabin_karp.cpp.