Skip to content

Commit 7261cec

Browse files
Update and rename Boyer Moore.cpp to Boyer_Moore.cpp
1 parent 59999d4 commit 7261cec

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@ using namespace std;
88
# define NO_OF_CHARS 256
99

1010
// The preprocessing function for Boyer Moore's
11-
// bad character heuristic
12-
void badCharacter( string str, int size, int badchar[NO_OF_CHARS])
11+
// bad Character function
12+
void badCharacter( string str, int size, int badChar[NO_OF_CHARS])
1313
{
1414
// Fill the last occurrence of a character
1515
for (int i = 0; i < size; i++)
16-
badchar[(int) str[i]] = i;
16+
badChar[(int) str[i]] = i;
1717
}
1818

1919
/* A pattern searching function that uses Bad
20-
Character Heuristic of Boyer Moore Algorithm */
20+
Character function of Boyer Moore Algorithm */
2121
void search( string txt, string pat)
2222
{
2323
int m = pat.size();
2424
int n = txt.size();
2525

26-
int badchar[NO_OF_CHARS]={-1};
26+
int badChar[NO_OF_CHARS]={-1};
2727

28-
/* Fill the bad character array by function badCharHeuristic() for given pattern */
29-
badCharacter(pat, m, badchar);
28+
/* Fill the bad character array by function badChar() for given pattern */
29+
badCharacter(pat, m, badChar);
3030

3131
int s = 0; // s is shift of the pattern with respect to text
3232

@@ -53,7 +53,7 @@ void search( string txt, string pat)
5353
The condition s+m < n is necessary for
5454
the case when pattern occurs at the end
5555
of text */
56-
s += (s + m < n)? m-badchar[txt[s + m]] : 1;
56+
s += (s + m < n)? m-badChar[txt[s + m]] : 1;
5757

5858
}
5959

@@ -66,7 +66,7 @@ void search( string txt, string pat)
6666
occurrence of bad character in pattern
6767
is on the right side of the current
6868
character. */
69-
s += max(1, j - badchar[txt[s + j]]);
69+
s += max(1, j - badChar[txt[s + j]]);
7070
}
7171
}
7272

@@ -79,7 +79,7 @@ int main()
7979
return 0;
8080
}
8181

82-
//#description
82+
//description
8383
//Boyer Moore algorithm starts matching from the last character of the pattern
8484
//It preprocesses the pattern and creates different arrays for last occurrence of each of the characters in string .
85-
// At every step, it slides the pattern by the max of the slides suggested .
85+
//At every step, it slides the pattern by the max of the slides suggested .

0 commit comments

Comments
 (0)