parttherefore we may impose the condition pd pj when solving for this alows us to fully utilize the information from the inequality in the guard of this loop branch string pattern shifted pattern = =- (shift = =- (shift fig shifting pattern past position of last character the essential result is that the value apparently is determined by the pattern alone and does not depend on the text string we shall denote for given as dj the auxiliary table may be computed before starting the actual searchthis computation amounts to precompilation of the pattern this effort is evidently only worthwhile if the text is considerably longer than the pattern ( <nif multiple occurrences of the same pattern are to be foundthe same values of can be reused sothe computation of dj is the search for the longest matching sequence pd[ ]- pj- [jpj- with the additional constraint of pd[jpj evidentlythe computation of dj presents us with the first application of string searchand we may as well use the fast kmp version itself procedure search (var psarray of charmnintegervar rinteger)(adens _kmp *(*search for pattern of length in text of length nm <mmax*(*if is foundthen indicates the position in sotherwise - *var ijkintegerdarray mmax of integerbegin (*compute from * [ :- if [ [ then [ : else [ :- endj : : while ( ( [jp[ ]do : [kelsif - do (( or ( [jp[ ]*incj )inck )if [jp[kthen [ : else [ : [kendassertd[jd( )end(*search proper* : :