File tree Expand file tree Collapse file tree
src/main/java/com/thealgorithms/searches Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com .thealgorithms .searches ;
2+
23/**
34 * Boyer-Moore string search algorithm
45 * Efficient algorithm for substring search.
5- *
6- * @see <a href="https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm">
7- * https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm</a>
6+ * https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search-algorithm
87 */
9-
108public class BoyerMoore {
119
1210 private final int R ;
@@ -17,10 +15,12 @@ public BoyerMoore(String pat) {
1715 this .pattern = pat ;
1816 this .R = 256 ;
1917 this .right = new int [R ];
20- for (int c = 0 ; c < R ; c ++)
18+ for (int c = 0 ; c < R ; c ++) {
2119 right [c ] = -1 ;
22- for (int j = 0 ; j < pat .length (); j ++)
20+ }
21+ for (int j = 0 ; j < pat .length (); j ++) {
2322 right [pat .charAt (j )] = j ;
23+ }
2424 }
2525
2626 public int search (String text ) {
@@ -36,8 +36,9 @@ public int search(String text) {
3636 break ;
3737 }
3838 }
39- if (skip == 0 )
39+ if (skip == 0 ) {
4040 return i ;
41+ }
4142 }
4243 return -1 ;
4344 }
You can’t perform that action at this time.
0 commit comments