diff --git a/18.RabinKarp.cpp b/18.RabinKarp.cpp new file mode 100644 index 0000000..0ceb5a4 --- /dev/null +++ b/18.RabinKarp.cpp @@ -0,0 +1,59 @@ +/* + * This program searches for a pattern in a text using + * Rabin - Karp Algorithm + * + * Coded by: Abdurrezak Efe + * + * */ + + + +#include +#include +#include +using namespace std; + +int prime = 7; +int pattern_hash; +vector indexes; + +int hasher(string s) +{ + int result = 0; + for(int i=0;i> text >> pattern; + + pattern_hash = hasher(pattern); + rabin_karp(text, pattern); + + for(int i=0;i