Prefix Function
For each prefix, the length of its longest proper prefix that is also a suffix, built by falling back through shorter borders.
String Matching: Prefix function of a pattern
i = 1, prefix "ab". Start from pi[0] = 0. No border can be extended, so pi[1] = 0.
Cost
- Best
- O(m)
- Average
- O(m)
- Worst
- O(m)
- Space
- O(m)
Before this
Leads to
Topics that need this one first.
Taught by the same lesson
String Matching covers these too, in the same run.