500
Recall that a tree is a data structure in which each node has some value along with zero or more children. A binary tree, meanwhile, is a tree in which each node has at most two children. A binary search tree, finally, is a binary tree, the value of whose root is (1) greater than that of its left child, if any, and any descendants thereof and (2) less than that of its right child, if any, and any descendants thereof. Moreover, each child is itself the root of a binary search tree. To be clear, a binary search tree is necessarily a binary tree, but a binary tree is not necessarily a binary search tree. For simplicity, assume that trees' values are integers and that trees may not contain duplicate values.
Suppose that a C function called find is supposed to return true if any node in a binary tree contains a particular value, else it is supposed to return false. Complete the below definition of find, based on your definition of node. Do not assume that tree is non-NULL or that tree is a binary search tree.
bool
find(node *tree, int n)
{
bool
find(node *tree, int n)
{
if (tree == NULL)
return false;
else if (tree->n == n)
return true;
else if (find(tree->left, n))
return true;
else if (find(tree->right, n))
return true;
else
return false;
}