guys, i am having trouble printing the LCS.
This is the algorithm i am following to get the count of the LCS.
int main(void)
{
printf("\nThe LCS is %d",LCS(0,0));
}
int LCS(int m, int n)
{
if(m==l1 || n==l2)
return 0;
if(X[m] == Y[n])
return 1 + LCS(X[m+1],Y[n+1]);
else
return max( LCS(X[m],Y[n+1], LCS(X[m+1],Y[n]));
}
Now where do i put a printf ????
I tried putting at the line where both are equal, ie, if(X[m] == Y[n]), but obviously it doesnt work...