Skip to content

Instantly share code, notes, and snippets.

@icarofreire
Last active August 29, 2015 14:07
Show Gist options
  • Save icarofreire/fb2e9231d8298514cbaf to your computer and use it in GitHub Desktop.
Save icarofreire/fb2e9231d8298514cbaf to your computer and use it in GitHub Desktop.
Função de processamento pré - KMP.
int* meu_pre_kmp(char *pattern)
{
int *g = malloc(sizeof(int)*strlen(pattern));
int i, n=0, estado=1;
repi(i, 1, strlen(pattern))
{
if( pattern[n] != pattern[i] )
{
g[i]=0;
}else{
g[i]=estado;
estado++;
n++;
}
}
return g;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment