Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f9a8c88

Browse files
committedApr 24, 2018
Add Rabin.
1 parent d126b23 commit f9a8c88

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed
 

‎README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
* **String**
4242
* [Levenshtein Distance](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/levenshtein-distance) - minimum edit distance between two sequences (DP approach)
4343
* [Hamming Distance](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/hamming-distance) - number of positions at which the symbols are different
44-
* [Knuth–Morris–Pratt algorithm](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/knuth-morris-pratt) - substring search
45-
* Rabin Karp
44+
* [Knuth–Morris–Pratt Algorithm](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/knuth-morris-pratt) - substring search
45+
* [Rabin Karp Algorithm](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/rabin-karp) - substring search
4646
* Longest common subsequence
4747
* longest common substring
4848
* **Search**
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Rabin Karp Algorithm
2+
3+
In computer science, the Rabin–Karp algorithm or Karp–Rabin algorithm
4+
is a string searching algorithm created by Richard M. Karp and
5+
Michael O. Rabin (1987) that uses hashing to find any one of a set
6+
of pattern strings in a text.
7+
8+
## Complexity
9+
10+
For text of length `n` and `p` patterns
11+
of combined length `m`, its average and best case running time is
12+
`O(n + m)` in space `O(p)`, but its worst-case time is `O(n * m)`.
13+
14+
## Application
15+
16+
A practical application of the algorithm is detecting plagiarism.
17+
Given source material, the algorithm can rapidly search through a paper
18+
for instances of sentences from the source material, ignoring details
19+
such as case and punctuation. Because of the abundance of the sought
20+
strings, single-string searching algorithms are impractical.
21+
22+
## References
23+
24+
[Wikipedia](https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm)

0 commit comments

Comments
 (0)
Please sign in to comment.