Алгоритмы поиска
Download 438.04 Kb.
|
8-ma`ruza
- Bu sahifa navigatsiya:
- Rabin-Karp algoritmi
- Boyer-Mur algoritmi
Rabin-Karp algoritmi
Rabin-Karp algoritmi
Rabin-Karp algoritmiint rk_substring_search(const char s[], int N, const char q[], int M) { int k; // matnda namuna ko`chirish int hs = rk_hash(s, M); int hq = rk_hash(q, M); for (k = 0; k < N-M; ++k) { int j; // namuna ko`chirishif (hs == hq) for (j = 0; s[k+j]==q[j]; ++j) if (j == M-1) return k; // topildi // rk_hash_update ishlash vaqti O(1) hs = rk_hash_update(hs, s[k], s[k+M], M); } return -1; // topilmadi}Boyer-Mur algoritmi
int Robin_Carp_Matcher(char s[], char q[], int d, int p) {Download 438.04 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling