00:01
Okay, so in this question we have a pattern of m characters and we want to see how many times it occurs in this text end using a naive string matcher.
00:12
So to do this, we first have to understand what this code does.
00:16
So suppose i have a string a b, c, d, f, g, h, i, j, k, l.
00:23
So this is my text and i want to see if i can find the characters a, z, z, i know this doesn't occur but let's just say i wanted to find this.
00:37
So what it does is it compares, well it should compare this character to the first three characters.
00:44
So it first compares with these three characters, then he compares with the next three characters, then he compares with the next three characters and it compares with the next three characters and so on, so on until you get to the last three characters.
00:58
So now we have to think how many times does it actually perform this comparison within with three characters, three characters of pattern, to three characters from the text.
01:16
So what we see here is that the way the first character starts, so the first comparison started with the first letter here, and then it went to the second letter, the third letter to the fourth letter, and it continues on to the fifth, six, seven, eight, whatever, until this character right here.
01:31
So if this was one, two, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12.
01:36
So this is 12 numbers in total...