next up previous
Next: Up: Previous:

Information For Bad Character Heuristic



Compute-Last-Occurrence(P, m $\Sigma$)
$\;\;\;\;\;$foreach a $\in$$\Sigma$
$\;\;\;\;\;$ $\;\;\;\;\;$ \(\lambda[a]\) = 0
$\;\;\;\;\;$for j = 1 to m
$\;\;\;\;\;$ $\;\;\;\;\;$$\lambda$[P[j]] = j
$\;\;\;\;\;$return $\lambda$



Running time: O( $\mid \Sigma \mid + m$)



If mismatch at P[j] $\neq$ T[s+j], then shift (j - $\lambda$[T[s+j]]).



Note: Shift could be negative, in which case ignore the shift value and use Good Suffix shift which always has a positive value.


next up previous
Next: Up: Previous: