I don't know if I'd call it B-M-H either. B-M-H-S, perhaps. :-)
There are three crucial differences over Horspool as far as I can see:
- Single-bad-character-shift is extended to multi-character, or rather, multi-bit in this case.
That much is pretty obvious when working with bit-strings.
- The shift values are compressed. If the extra work is offset by space savings, I cannot tell.
- A window limit is enforced. In this instance, the biggest shift is (delta[255] = 106688) bits.
Larger exponent base for (tail end of) the delta[] could cover the full range, so the last two points are separate issues.
Window limit actually makes a lot of sense. In a random run of characters, they'll all be seen soon enough. There won't be many deltas above 5*(1<<BITS) #1; any further preprocessing would be wasted effort. (On random patterns.) Or, to put it another way, the limit acknowledges the hardware constraints (register, cache, memory sizes).
The same limit can apply to other searches— B-M, skip search, etc. With the limit in place, they all become O(1) in preprocessing. Effectively, you only search for a part of the pattern. The slow compare, however, is done on the full pattern.
#1 exp(-5) = .0067
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.