Below is the code for KMP failure function :

int F[]; //assume F is a global arary.
int Fill-Prefix-Table(int P[], int m)
{
int i,j;
F[0]=0;
j=0;
i=1;
while(i < m)
{
if(P[i] == P[j])
{
  F[i]=j+1;
  i++;
  j++;
}
else if(j > 0)
{
  j = F[j-1];
}
else
{
 F[i]=0;
 i++;
}
}
}

In the above function,

in the "else if" case, why is it j = F[j-1] ? Plz explain with an example..

Thanx in advance :)
*
*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to