Skip to content

Commit a448bfb

Browse files
authored
Update BoyerMoore.java
1 parent d503359 commit a448bfb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/com/thealgorithms/searches/BoyerMoore.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package com.thealgorithms.searches;
2+
13
/**
24
* Boyer-Moore string search algorithm
35
* Efficient algorithm for substring search.
@@ -11,15 +13,13 @@ public class BoyerMoore {
1113

1214
public BoyerMoore(String pat) {
1315
this.pattern = pat;
14-
this.R = 256; // extended ASCII
16+
this.R = 256;
1517
this.right = new int[R];
1618

17-
// Initialize all occurrences as -1
1819
for (int c = 0; c < R; c++) {
1920
right[c] = -1;
2021
}
2122

22-
// Fill the actual value of last occurrence of a character
2323
for (int j = 0; j < pat.length(); j++) {
2424
right[pat.charAt(j)] = j;
2525
}
@@ -42,9 +42,9 @@ public int search(String text) {
4242
break;
4343
}
4444
}
45-
if (skip == 0) return i; // found
45+
if (skip == 0) return i;
4646
}
47-
return -1; // not found
47+
return -1;
4848
}
4949

5050
public static int search(String text, String pattern) {

0 commit comments

Comments
 (0)