==Псевдокод==
int preSo algorithm bitap_search(char *xtext : string, int pattern : string) returns string m, unsigned int S[]:= length(pattern) { unsigned int j, lim; if m == 0 return text int i; /* Initialize the bit array R. */ for (i R := new array[m+1] of bit, initially all 0; i < ASIZE; ++i) S R[i0] = ~0; 1 for (lim = i = 0, j = 1; i < mlength(text); i ++i, j <<= 1) { S[x[i]] &= ~j; lim |= j; } lim = ~(lim>>1); return(lim); } void SO(char *x, int m, char *y, int n) { unsigned int lim, state; unsigned int S[ASIZE]; int j; if (m > WORD) error("SO: Use pattern size <= word size"); /* Preprocessing Update the bit array. */ lim for k = preSo(x, m, S); /* Searching */ for (state k >= ~0, j 1; k -= 0; j < n; ++j) { 1: state R[k] = R[k-1] & (state<<1) | Stext[yi] == pattern[jk-1]]; ) if (state < lim) R[m]: OUTPUT return (j text+i - m ) + 1); } } return nil
==Корректность==