小编Ars*_*rma的帖子

Rabin-Karp 算法代码中的负哈希值

我从这个网站了解拉宾-卡普算法:https://www.geeksforgeeks.org/rabin-karp-algorithm-for-pattern-searching/

他们的算法的 C++ 代码如下:

#include <bits/stdc++.h> 
using namespace std; 
  
// d is the number of characters in the input alphabet  
#define d 256  
  
/* pat -> pattern  
    txt -> text  
    q -> A prime number  
*/
void search(char pat[], char txt[], int q)  
{  
    int M = strlen(pat);  
    int N = strlen(txt);  
    int i, j;  
    int p = 0; // hash value for pattern  
    int t = 0; // hash value for txt  
    int h = 1;  
  
    // The …
Run Code Online (Sandbox Code Playgroud)

c++ algorithm hash data-structures

5
推荐指数
1
解决办法
253
查看次数

标签 统计

algorithm ×1

c++ ×1

data-structures ×1

hash ×1