The string matching algorithm is generally divided into two phases: th
e preprocessing phase to obtain the shift tables and the main matching
process with the tables. In the off-line version, we computed the tab
les after the whole pattern has been input, while in the on-line versi
on, we computed the tables as the new character of the pattern is inpu
t, that is, on the fly. The shift table for the Knuth-Morris-Pratt (KM
P) is computed from left to right, and hence suitable for the on-line
version. The d-table and Horspool table in the Boyer-Moore (BM) algori
thm are also computed from left to right in linear time. We show in th
is paper that the dd-table for the BM algorithm can be computed in O(m
log m) expected time from left to right for a random pattern, and hen
ce can be incorporated into an on-line version.