Complete the code to compare the current node's value with the target key.
if (root->data [1] key) { return root; }
The search checks if the current node's data is equal to the key.
Complete the code to decide to search in the left subtree if the key is smaller.
if (key [1] root->data) { return searchBST(root->left, key); }
If the key is less than the current node's data, search the left subtree.
Fix the error in the recursive call to search the right subtree when key is greater.
if (key [1] root->data) { return searchBST(root->right, key); }
If the key is greater than the current node's data, search the right subtree.
Fill both blanks to complete the base case and recursive search logic.
if (root == NULL) { return [1]; } if (key == root->data) { return root; } else if (key [2] root->data) { return searchBST(root->left, key); } else { return searchBST(root->right, key); }
Return NULL if node is not found. Use '<' to decide left subtree search.
Fill all three blanks to complete the BST search function.
struct Node* searchBST(struct Node* root, int key) {
if (root == [1]) {
return [2];
}
if (key == root->data) {
return root;
} else if (key [3] root->data) {
return searchBST(root->left, key);
} else {
return searchBST(root->right, key);
}
}Check if root is NULL, return NULL. Use '<' to search left subtree.
