By fetching the
S underlying the last character of the pattern we gain more information about matches in this area of the text.- We are not standing on a match (because
Sisn'tE). - We wouldn't find a match even if we slid the pattern down by 1 (because
Sisn'tL). - We wouldn't find a match even if we slid the pattern down by 2 (because
Sisn'tP). - Etc.
S doesn't occur in the pattern at all we can slide the pattern down by its own length without missing a match. This will align the S we just found with an imaginary one just beyond the front of the pattern. This shift can be precalculated for every element of the alphabet and stored in a table.
Tidak ada komentar:
Posting Komentar