The good suffix rule presents a complementary method to enhance our search for valid shifts. To identify when the good suffix rule is applicable, let's look at the example given in the following table:
i | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
T | A | A | B | A | B | A | B | A | C | B | A | C | A | B | B | C | A | B |
P | A | A | C | C | A | C | C | A | C |
When found in a situation where we have matched a suffix of P but have found a mismatch, using the good suffix rule, and considering t as the matched suffix, we can try to find the next shift that solves the mismatch by carrying out either of the following cases:
- Find another occurrence of t to the left in P
- Find a prefix of P which matches a suffix of ...