sure, this is the main function that is doing the work, and there is some subfunctions that I didn't place, because the codes are too long. What I am seeking for is if there is any algorithms that do this? (the function is described in my previous message)
For e.g. in sorting, there are insertion sort, counting sort, bubble sort, etc.... so is there any good algorithms that do the same task as mine?
Code:
void NormalSituation(unsigned char *str, unsigned int *suffixes, unsigned int rightboundary, unsigned int *LCP, CommonPatternPtr *cp, CommonPatternPtr *tailPtr, unsigned int j, unsigned int filelength)
{
unsigned int tempLCP, LCPlength;
int k=0,i;
k = rightboundary;
while ((*LCP==0) && (j!=k))
{
if (GetReadBit(&str[suffixes[k]]) && GetReadBit(&str[suffixes[k]-1]))
{
if ((suffixes[j] != (suffixes[k] - 1)))
{
tempLCP = FindLCP(str, suffixes, j, k, filelength);
if (tempLCP>*LCP)
{
*LCP = tempLCP;
NewLCPParameters(LCP, tempLCP,j, k, cp, tailPtr, suffixes);
}
}
}
k--;
}
if (*LCP > 0)
{
for (i=k; i>j; i--)
{
if (GetReadBit(&str[suffixes[i]]) && GetReadBit(&str[suffixes[i]-1]))
{
if ((suffixes[j] != (suffixes[i] - 1)))
{
LCPlength = FindLCP2(str, suffixes, j, i, filelength, tempLCP);
if (LCPlength == *LCP) //exist a CP node with the same LCP
AddLCPParameters(LCP, tempLCP, i, cp, tailPtr, suffixes);
}
}
}
AddLCPParameters(LCP, tempLCP,j, cp, tailPtr, suffixes);
SetReadBit(tailPtr, str, suffixes);
}
}