Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Boyer–Moore string-search algorithm
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Description==== {{float begin|side=right|width=380px}} | -||-||-||-||X||-||-||K||-||-||-||-||- |- | M||A||N||P||A||<span style="color:#0000FF">N</span>||<span style="color:#0000FF">A</span>||<span style="color:#0000FF">M</span>||A||N||A||P||- |- | A||<span style="color:#FF0000">N</span>||<span style="color:#FF0000">A</span>||<span style="color:#FF0000">M</span>||P||<span style="color:#0000FF">N</span>||<span style="color:#0000FF">A</span>||<span style="color:#0000FF">M</span>||-||-||-||-||- |- | -||-||-||-||A||<span style="color:#FF0000">N</span>||<span style="color:#FF0000">A</span>||<span style="color:#FF0000">M</span>||P||N||A||M||- {{float end|Demonstration of good-suffix rule with pattern '''P''' {{=}} '''ANAMPNAM'''. Here, '''''t''''' is '''T'''[6..8] and '''''{{prime|t}}''''' is '''P'''[2..4].}} The good-suffix rule is markedly more complex in both concept and implementation than the bad-character rule. Like the bad-character rule, it also exploits the algorithm's feature of comparisons beginning at the end of the pattern and proceeding towards the pattern's start. It can be described as follows:<ref name = "ASTS"> {{Citation | last = Gusfield | first = Dan | title = Algorithms on Strings, Trees, and Sequences | publisher = Cambridge University Press | orig-date =1997 | year = 1999 | edition = 1 | chapter = Chapter 2 - Exact Matching: Classical Comparison-Based Methods | pages = 19–21 | isbn = 0-521-58519-8 }} </ref> <blockquote> Suppose for a given alignment of '''''P''''' and '''''T''''', a substring '''''t''''' of '''''T''''' matches a suffix of '''''P''''' and suppose '''''t''''' is the largest such substring for the given alignment. # Then find, if it exists, the right-most copy '''''{{prime|t}}''''' of '''''t''''' in '''''P''''' such that '''''{{prime|t}}''''' is not a suffix of '''''P''''' and the character to the left of '''''{{prime|t}}''''' in '''''P''''' differs from the character to the left of '''''t''''' in '''''P'''''. Shift '''''P''''' to the right so that substring '''''{{prime|t}}''''' in '''''P''''' aligns with substring '''''t''''' in '''''T'''''. # If '''''{{prime|t}}''''' does not exist, then shift the left end of '''''P''''' to the right by the least amount (past the left end of '''''t''''' in '''''T''''') so that a prefix of the shifted pattern matches a suffix of '''''t''''' in '''''T'''''. This includes cases where '''''t''''' is an exact match of '''''P'''''. # If no such shift is possible, then shift '''''P''''' by '''m''' (length of P) places to the right. </blockquote>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)