==Псевдокод==
algorithm bitap_search int preSo(text : stringchar *x, pattern : string) returns string int m := length(pattern, unsigned int S[]){ if m == 0 unsigned int j, lim; return text int i; /* Initialize the bit array R. */ R : for (i = new array[m0; i < ASIZE; ++1] of bit, initially all 0i) R S[0i] = 1~0; for (lim = i = 0, j = 1; i < m; ++i , j << length(text= 1){ S[x[i]] &= ~j; lim |= j; i + } 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"); /* Update the bit array. Preprocessing */ for k lim = preSo(x, m, S); k > /* Searching */ for (state = ~0, j = 10; j < n; k -++j) { state = (state<<1: R) | S[k] = Ry[k-1j] & (text[i] == pattern[k-1]); if R[m]:(state < lim) return OUTPUT(text+i j - m) + 1); } return nil }
==Корректность==