Which of the following is false about a binary search tree code example
Example 1: binary tree search
/* This is just the seaching function you need to write the required code.
Thank you. */
void searchNode(Node *root, int data)
{
if(root == NULL)
{
cout << "Tree is empty\n";
return;
}
queue<Node*> q;
q.push(root);
while(!q.empty())
{
Node *temp = q.front();
q.pop();
if(temp->data == data)
{
cout << "Node found\n";
return;
}
if(temp->left != NULL)
q.push(temp->left);
if(temp->right != NULL)
q.push(temp->right);
}
cout << "Node not found\n";
}
Example 2: binary tree vs binary search tree
Binary tree - each node can have at most 2 nodes, Binary Search tree - is a binary tree and put smaller values on the left and larger values on the right of the root.