Code:
/*
Given a binary tree, return true if a node
with the target data is found in the tree. Recurs
down the tree, chooses the left or right
branch by comparing the target to each node.
*/
static int lookup(struct node* node, int target) {
// 1. Base case == empty tree
// in that case, the target is not found so return false
if (node == NULL) {
return(false);
}
else {
// 2. see if found here
if (target == node->data) return(true);
else {
// 3. otherwise recur down the correct subtree
if (target < node->data) return(lookup(node->left, target));
else return(lookup(node->right, target));
}
}
}
i thought there is no true/false in C only 0 and not 0
??
if this function return true or false how come it defined as integer type??
what the meaning of static in the signature of this function
i know that in JAVA we put static when we dont want to call a constructor
and straight away get the data from the variable
but here its a function and its not java
??