Help in Rabin karp algorithm.

Правка en1, от Matuagkeetarp, 2020-05-26 15:15:14

I was learning rabin karp algorithm and solving a basic problem of finding indices of pattern in a string with the help of string hashing technique. But the code is just not printing out anything.

I used this algorithm yesterday to solve a problem and got AC but now I'm unable to find where's the issue.

here's my code-


#include 
using namespace std;

typedef long long ll;
ll mod = 1000000007;
#define max 100005
int p = 31;

ll hashfunction[max], power[max];

void precompute(string text, int n){

    power[0]=1;
    hashfunction[0] = text[0]-'a'+1;
    ll pow = p;
    for(int i=1; i solve(string text, string pattern){

    vector v;

    precompute(text, text.length());
    ll hashofpattern = computeHashofstring(pattern);

    int left=0, right=pattern.length()-1;
    while (right> text >> pattern;

    vector v = solve(text, pattern);

    for(int i=0; i<< v[i] << '\n';

    return 0;
}
Теги #c++, #algorithms, #data structures, #string, #string matching, #strings, #algos

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский Matuagkeetarp 2020-05-26 15:19:00 1546
en3 Английский Matuagkeetarp 2020-05-26 15:17:13 33 Tiny change: 'rn v;\n}\n\nint main' -> 'rn v;\n}\n</pre>\n<pre class="prettyprint">\nint main'
en2 Английский Matuagkeetarp 2020-05-26 15:16:25 74
en1 Английский Matuagkeetarp 2020-05-26 15:15:14 1814 Initial revision (published)