And the end will just be i plus 1 times the segment length.

But we want to make sure that we don't run past the end of p.

So I'm going to take the minimum of this, and the length of p.

>> So you segment length could either be a little bit longer or

a little bit shorter than a perfectly even length of the different partitions.

So you're just making up for that basically by re-sizing the last partition

so that it makes up for it, right?

Right, because ping might not be,

it's length might not be a perfect multiple of n plus one.

So make sure we don't go past the end of the string.

>> Okay.

So now, let's do our preprocessing, okay, our object.

[SOUND] I'm just going to use the sub string of p that we just calculated,

and we have to pass in the alphabet.

>> That's going to do all our Boyer-Moore pre-processing for us.

So it's going to make the tables for the good suffix rule and

the bad character rule.

>> Yep.

And now we can just run our Boyer-Moore algorithm.