Loading topic
T has length n, the pattern P has length m, and a match at shift i means T[i:i+m] == P.3 min readpi[i] means: the length of the longest proper border of p[0..i]. It also assumes you can read Python loops and Big-O notation. The goal is to compute the whole pi array in O(m) time for a pattern of length m.3 min readprefix_function from the previous chapter. Recall that pi[i] is the length of the longest proper border of p[0..i]. Here that table drives a search that reads each text character once and never moves backward in t3 min readprefix_function and kmp_search from the earlier chapters. You should be comfortable reading Python and tracing a loop by hand. The goal here is to check the search on inputs that often break string matchers: overlapping occurrences, an empty pattern, a 3 min readpi, the meaning of a border, and the KMP search loop from the previous chapters. The question here is a reasonable worry. When KMP hits a mismatch, it jumps k straight to pi[k - 1] and never looks at the text again. Could that jump skip3 min readpi[i] is the length of the longest proper border of s[0..i]. It also assumes you can read Python and Big-O notation. The prefix function does more than drive KMP search. With one subtraction, it also tells you how a string 3 min readpi and the KMP search loop from earlier chapters. You should also be comfortable with Python dictionaries and Big-O notation.3 min read