Skip to content

Commit 4b09fab

Browse files
committed
add: initial implementation of Rabin-Karp algorithm for string matching
1 parent 26828a7 commit 4b09fab

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/com/thealgorithms/strings/PatternSearchUsingRabinKarpAlgo.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package com.thealgorithms.strings;
22
import java.util.*;
33

4+
/*
5+
https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm
6+
The Rabin-Karp algorithm calculates a hash value for the pattern and a hash value for a sliding window
7+
of text in the same length as the pattern. If the hash values match, it checks character by character
8+
to confirm that it's an exact match.
9+
*/
10+
411
public class PatternSearchUsingRabinKarpAlgo {
512

613
// I'm using Rabin-Karp algorithm that uses hashing to find pattern strings in a text.

0 commit comments

Comments
 (0)