Complete the code to check if the current node is null in the BST search function.
if (root == [1]) { return false; }
In C++, the correct way to check for a null pointer is using nullptr.
Complete the code to compare the search key with the current node's data.
if (key == root->[1]) { return true; }
The node's stored value is typically accessed with data in BST nodes.
Fix the error in the recursive call to search in the left subtree.
return searchBST(root->[1], key);
To search in the left subtree, we must use root->left.
Fill both blanks to complete the recursive search in the right subtree when key is greater.
if (key > root->[1]) { return searchBST(root->[2], key); }
We compare with root->data and recurse into root->right when key is greater.
Fill all three blanks to complete the BST search function.
bool searchBST(Node* root, int key) {
if (root == [1]) return false;
if (key == root->[2]) return true;
if (key < root->[3]) return searchBST(root->left, key);
else return searchBST(root->right, key);
}The function checks if root is nullptr, compares key with root->data, and recurses accordingly.
