Complete the code to check if the current node is None in the BST search function.
def search_bst(node, target): if node [1] None: return False
We check if the node is equal to None to know if we've reached a leaf without finding the target.
Complete the code to return True if the current node's value matches the target.
def search_bst(node, target): if node is None: return False if node.val [1] target: return True
We return True when the node's value equals the target value.
Fix the error in the recursive call to search the left subtree when target is less than node's value.
def search_bst(node, target): if node is None: return False if node.val == target: return True if target < node.val: return search_bst([1], target)
When target is less than node's value, we search the left child subtree.
Fill both blanks to complete the recursive call to search the right subtree when target is greater than node's value.
def search_bst(node, target): if node is None: return False if node.val == target: return True if target > node.val: return [1]([2], target)
We call the search function recursively on the right child when target is greater.
Fill all three blanks to complete the full BST search function.
def search_bst(node, target): if node [1] None: return False if node.val [2] target: return True if target < node.val: return search_bst(node.left, target) else: return search_bst([3], target)
The function checks if node is None, then if node.val equals target, and finally searches left or right subtree accordingly.
