Embed presentation
Downloaded 15 times





![Boyer-Moore algorithm Pseudocode
Input: String T (text with n characters and P (pattern) with m characters
Output: Index of the first substring of Text matching Pattern.
i <-- m - 1
j <-- m - 1
repeat
if P[j] = T[i] then
if j = 0 then
return i {a match is found}
else {checking the next character}
i <-- i - 1
j <-- j - 1
else { P[j] <> T[i] move the pattern}
i <-- i + m - j - 1
i <-- i + max(j - last(T[i]), match(j))
j <-- m-1
until i > n - 1
return “ no match”](https://image.slidesharecdn.com/boyremoorealgorithm-170127123557/75/Boyre-Moore-Algorithm-Computer-Science-6-2048.jpg)


The Boyer-Moore algorithm, developed by Robert S. Boyer and J. Strother Moore in 1977, is a text pattern searching technique that compares the pattern against text from right to left. Upon encountering a mismatch, it shifts the pattern to align with a previously matched good suffix or skips to the next potential position based on bad character rules. The pseudocode for the algorithm outlines how the pattern and text indices are manipulated to efficiently find substring matches.





![Boyer-Moore algorithm Pseudocode
Input: String T (text with n characters and P (pattern) with m characters
Output: Index of the first substring of Text matching Pattern.
i <-- m - 1
j <-- m - 1
repeat
if P[j] = T[i] then
if j = 0 then
return i {a match is found}
else {checking the next character}
i <-- i - 1
j <-- j - 1
else { P[j] <> T[i] move the pattern}
i <-- i + m - j - 1
i <-- i + max(j - last(T[i]), match(j))
j <-- m-1
until i > n - 1
return “ no match”](https://image.slidesharecdn.com/boyremoorealgorithm-170127123557/75/Boyre-Moore-Algorithm-Computer-Science-6-2048.jpg)

Introduces the Boyer-Moore algorithm, defined by Robert S. Boyer and J. Strother Moore in 1977.
Explains the pattern matching process comparing from right to left and shifting right on mismatch.
Describes the concept of a Bad Character in pattern matching, indicating the character that causes a mismatch.
Discusses shifting strategy when a good suffix is found, ensuring alignment with the text on the new position.
Illustrates the good suffix table for the Boyer-Moore algorithm using the pattern '12312412'.
Provides the pseudocode for the Boyer-Moore algorithm to find substring matches in a text.
Concludes with a summary of the Boyer-Moore algorithm and provides a link for further details.