Изменения
→Псевдокод
*/
l = '''lcp'''(p, s[array[0]]) ; r = '''lcp'''(p, s[array[n - 1]]);
'''if''' (l == w or p < s[array[0]])
L<tex>_p</tex> = 0 ; '''else''' ''' if ''' (p > s[array[n - 1]) L<tex>_p</tex> = n;
'''else''' {
L = 0; R = n - 1;
'''while''' (R - L > 1) '''do''' {
M = (L + R) / 2; m<tex>_l</tex> = '''lcp'''(array[L], array[M]); m<tex>_r</tex> = '''lcp'''(array[M], array[R]);
'''if''' (l >= r)
'''if''' (m<tex>_l</tex> >= l)
m = l + '''lcp'''<tex>_l</tex>(s[array[M]], p);
'''else'''
m = m<tex>_l</tex>;
'''else'''
'''if''' (m<tex>_r</tex> >= r)
m = r + '''lcp'''<tex>_r</tex>(s[array[M]], p);
'''else'''
m = m<tex>_r</tex>;
'''if''' (m == w || p <=<tex>_m</tex> s[array[M]]){
R = M; r = m;
} '''else''' {
L = M; l = m;
}
}
L<tex>_p</tex> = R ;
}