bool BinarySearchTree(node* root,int val)
{
node *next = root;
while (next != NULL) {
if (val == next->data) {
return true;
} else if (val < next->data) {
next = next->left;
} else {
next = next->right;
}
}
//not found
return false;
}
No comments:
Post a Comment