File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
src/main/java/com/thealgorithms/searches Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 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 ) {
You can’t perform that action at this time.
0 commit comments