Arash Farzan
2009-03-24 21:56:18 UTC
Some students observed that the example given in class does not produce
the worst-case behavior of the Boyer-Moore algorithm. In fact the
example given beats the suffix shift heuristic but the character jump
heuristic compensates for it.
It is indeed not easy to beat both heuristics at the same time: this
tells us about the power of the Boyer-Moore algorithm in practice.
However, I have this construction which theoretically beats both
heuristics and achieves the worst-case O(nm) running time:
T = (bb(ab)^(k-1))*
P = (ab)^k
for instance: T = bbababab bbababab bbababab bbababab ... (white spaces
are put for ease of read)
P = abababab
You can observe that the majority of shifts are shift by twos which
gives a O(nm) running time.
the worst-case behavior of the Boyer-Moore algorithm. In fact the
example given beats the suffix shift heuristic but the character jump
heuristic compensates for it.
It is indeed not easy to beat both heuristics at the same time: this
tells us about the power of the Boyer-Moore algorithm in practice.
However, I have this construction which theoretically beats both
heuristics and achieves the worst-case O(nm) running time:
T = (bb(ab)^(k-1))*
P = (ab)^k
for instance: T = bbababab bbababab bbababab bbababab ... (white spaces
are put for ease of read)
P = abababab
You can observe that the majority of shifts are shift by twos which
gives a O(nm) running time.