the algorithm sets m = 15, to start at the two-character string "AB" leading up to the current position, set i = 2, and continue matching from the current position. 1 2 m: 01234567890123456789012 S: ABC ABCDAB ABCD W: i: This time the match is complete, and the first character of the match is S[15]. Description of pseudocode for the search algorithm The above example contains all the elements of the algorithm. For the moment, we assume the existence of a "partial match" table T, described below, which indicates where we need to look for the start of a new match when a mismatch is found. The entries of T are constructed so that if we have a match starting at S[m] that fails when comparing S[m + i] to W[i], then the next possible match will start at index m + i - T[i] in S (that is, T[i] is the amount of "backtracking" we need to do after a mismatch). This has two implications: first, T[0] = -1, which indicates that if W[0] is a mismatch, we cannot backtrack and must simply check the next character; and second, although the next possible match will begin at index m + i - T[i], as in the example above, we need not actually check any of the T[i] characters after that, so that we continue searching from W[T[i]]. The following is a sample pseudocode implementation of the KMP search algorithm. algorithm kmp_search: input: an array of characters, S (the text to be searched) an array of characters, W (the word sought) output: an array of integers, P (positions in S at which W is found) an integer, nP (number of positions) define variables: an integer, j ← 0 (the position of the current character in S) an integer, k ← 0 (the position of the current character in W) an array of integers, T (the table, computed elsewhere) let nP ← 0 while j < length(S) do if W[k] = S[j] then let j ← j + 1 let k ← k + 1 if k = length(W) then (occurrence found, if only first occurrence is needed, m ← j - k may be returned here) let P[nP] ← j - k, nP ← nP + 1 let k ← T[k] (T[length(W)] can't be -1) else let k ← T[k] if k < 0 then let j ← j +