String Matching
String Matching
• Worst-case Complexity:
l et nP ← 0
l et T[ 0] ← - 1
• Compute the hash of next substring "bra" from the hash of "abr"
1. subtract number added for the first 'a' of "abr"
2. multiply by base
3. add the last ‘a’ of "bra", i.e. 97 × 256
• hash("bra") =
–