My resources were the following video, as well as this video.

Basically, in one of the videos they state that the good suffix table for the pattern **“ABCBAB”** is the following:

k | suffix | d2 |
---|---|---|

1 | B | 2 |

2 | AB | 4 |

3 | BAB | 4 |

4 | CBAB | 4 |

5 | BCBAB | 4 |

and for **“DRIDI”**:

k | suffix | d2 |
---|---|---|

1 | I | 2 |

2 | DI | 5 |

3 | IDI | 5 |

4 | RIDI | 5 |

If all of the above is correct, I can’t understand why in the first table, for k = 5, we have d2 = 4 (because we match the A with the suffix **“BCBAB”**?), where as in the second table for k = 4, we cannot do the same (match D with the D inside the suffix **“RIDI”**), hence why the value for d2 is the length of the pattern, i.e 5 and not 3.

What’s going on here?