hi,
int common(node *temp,int c,int d)
{
int a=0;
if(temp==NULL)
return 0;
else if(temp->a==c || temp->a==d)
return 1;
a=common(temp->left,c,d)+common(temp->right,c,d);
if(a==2)
{
printf("%d\n",temp->a);
// break;
return 0;
}
else
return a;
}
this is my recusrion code. Actually, I want to end this recusrion process by adding some statement where i have written "//break". I have return 0; to end this, but it will recurse without any use. I have to end my recusrion process when a==2, no matter how many recusrion are already called , or how many recusrion are still to be called. I just want my control to transfer back to main (from where it is called up) when that condition become true.(a==2 here) . please help in this case.
thanks in advance.