Didn't find a suitable title, forgive me for that, anyways
Im trying to analyze a recursion function of BST, which returns 1.
After my bad calculations, I got return value of 0, I want to understand what am I doing here wrong.
We call the function like that from main.c
: func_3(root, 9);
So sum = 9
Here's the block of code:
int func_3(struct node* node, int sum)
{
if (node == NULL)
return(sum == 0);
else
{
int subSum = sum - node->data;
return (func_3(node->left, subSum) || func_3(node->right, subSum));
}
}
My calculations: func(5,9) -> func3(3,4) -> func(1,1) -> returns subTree = sum = 0.