Also called Horspool's algorithm and Boyer-Moore-Horspool algorithm.
fresh numbers
The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from boyer-moore-horspool's own run on the numbers shown.
choose one
1question 1
Horspool looks for coa in cocoa. How many comparisons does it make?
the answer, and why
the answer is A
The table: c jumps 2, o 1, any other letter 3. Place 1: the text's c is not the pattern's a, 1, and c jumps 2. Place 3: a, o and c match, 3. a stands only last in coa, so it is not in the table: it jumps 3, past the end. That is 4.
place
letters above
comparisons
jump
1
coc
1
c: 2
3
coa
3, a match
a: 3
coa tried at 2 places of cocoa. Place 2 is jumped over.
if you chose another
BThat is brute force: it tries all 3 places and compares from the front, 3 + 1 + 3.
CThat counts place 3's matches but not place 1's comparison.
DThat tries place 2 as well, which c's jump of 2 skips.