what is the meaning of 'S[x[i]]' in the following algorithm program, i understand how '&','<<' and all other code of program, but not sure about 'S[x[i]]', because in it x[i] clearly does not refer to a index position for array S, because it would not make sense as in my example, x[0] = 97/'a' and my S array has a size limit of max 32.
int preSo(char *x, int m, unsigned int *S) {
unsigned int j, lim;
int i;
for (i = 0; i < ASIZE; ++i)
S[i] = ~0;
for (lim = i = 0, j = 1; i < m; ++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;
lim = preSo(x, m, S);
for (state = ~0, j = 0; j < n; ++j) {
state = (state<<1) | S[y[j]];
if (state < lim)
OUTPUT(j - m + 1);
}
}
void OUTPUT(int n)
{
printf("%d",n);
}
void main()
{
char * pattern="abg";
char * text ="abg and ade ac are not same as ad";
SO(pattern,3,text,28);
getch();
}
i am now adding my test result for value of S[x[0]], x[0] = 97 ,S[x[0]] = 3435973836, value of S[97] = 3341248 where is this value coming from.