From fec946385c82aed5ae5e28b81949aad190fa5afb Mon Sep 17 00:00:00 2001 From: Abdurrezzak Efe Date: Thu, 9 Nov 2017 22:41:51 +0200 Subject: [PATCH] Add files via upload --- 18.RabinKarp.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 18.RabinKarp.cpp 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