The Shift Table

The so-called match heuristic is used to compute the values of this data structure. For every suffix of the pattern, that eventually causes a mismatch, the length of a safe shift is stored.

Suppose the scan of the pattern is done right to left and a mismatch occurs at position j in the pattern.


pattern[j] differs from text[i+j-1].

If i+s is a starting position for the pattern in text then, the following conditions hold:

D(j) = min{s > 0: cond1(j, s) and cond2(j, s) hold}

In the mismatch situation described above

i = i + D(j)
is a safe shift.


Back to the Applet