Content deleted Content added
It was correct, in the version of the algorithm where we want to search for all occurrences of the word we'd store m found in previous line (rather than stop algorithm altogether, return statement is a little confusing) and continue. |
m Added line breaks for long lines in code example. |
||
Line 130:
an array of characters, W (the word sought)
'''output''':
an integer (the [[Zero-based numbering|zero-based]] position in S at which W is found
or -1 when W not found in S) '''define variables''':
Line 142 ⟶ 143:
'''if''' i = length(W) '''then'''
'''return''' m (or store/use occurrence)
'''let''' m ← m + i - T[i], i ← T[i] (preparing for search next occurrence,
T[length(W)] can't be -1)
'''else'''
'''if''' T[i] > -1 '''then'''
|