mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-26 23:21:18 +08:00
Add Rabin.
This commit is contained in:
parent
d126b23c3c
commit
f9a8c881cc
@ -41,8 +41,8 @@
|
|||||||
* **String**
|
* **String**
|
||||||
* [Levenshtein Distance](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/levenshtein-distance) - minimum edit distance between two sequences (DP approach)
|
* [Levenshtein Distance](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/levenshtein-distance) - minimum edit distance between two sequences (DP approach)
|
||||||
* [Hamming Distance](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/hamming-distance) - number of positions at which the symbols are different
|
* [Hamming Distance](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/hamming-distance) - number of positions at which the symbols are different
|
||||||
* [Knuth–Morris–Pratt algorithm](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/knuth-morris-pratt) - substring search
|
* [Knuth–Morris–Pratt Algorithm](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/knuth-morris-pratt) - substring search
|
||||||
* Rabin Karp
|
* [Rabin Karp Algorithm](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/rabin-karp) - substring search
|
||||||
* Longest common subsequence
|
* Longest common subsequence
|
||||||
* longest common substring
|
* longest common substring
|
||||||
* **Search**
|
* **Search**
|
||||||
|
24
src/algorithms/string/rabin-karp/README.md
Normal file
24
src/algorithms/string/rabin-karp/README.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Rabin Karp Algorithm
|
||||||
|
|
||||||
|
In computer science, the Rabin–Karp algorithm or Karp–Rabin algorithm
|
||||||
|
is a string searching algorithm created by Richard M. Karp and
|
||||||
|
Michael O. Rabin (1987) that uses hashing to find any one of a set
|
||||||
|
of pattern strings in a text.
|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
For text of length `n` and `p` patterns
|
||||||
|
of combined length `m`, its average and best case running time is
|
||||||
|
`O(n + m)` in space `O(p)`, but its worst-case time is `O(n * m)`.
|
||||||
|
|
||||||
|
## Application
|
||||||
|
|
||||||
|
A practical application of the algorithm is detecting plagiarism.
|
||||||
|
Given source material, the algorithm can rapidly search through a paper
|
||||||
|
for instances of sentences from the source material, ignoring details
|
||||||
|
such as case and punctuation. Because of the abundance of the sought
|
||||||
|
strings, single-string searching algorithms are impractical.
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
[Wikipedia](https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm)
|
Loading…
Reference in New Issue
Block a user