Rabin-Karp (RK) algorithm (Single String Search String Search)

From Algorithm Wiki
Jump to navigation Jump to search

Time Complexity

$O(mn)$

Space Complexity

$O({1})$ words

(Derived: only storing a rolling hash)

Description

Hashing-based, compare the text and patterns via their hash functions

Approximate?

Exact

Randomized?

No, deterministic

Model of Computation

Word RAM

Year

1987

Reference

https://pdfs.semanticscholar.org/c47d/151f09c567013761632c89e237431c6291a2.pdf