Complete the code to check if a value exists in a BST.
def search_bst(node, value): if node is None: return False if node.val == [1]: return True elif value < node.val: return search_bst(node.left, value) else: return search_bst(node.right, value)
The function compares the current node's value with the target value. If they are equal, it returns True.
Complete the code to decide which subtree to search next in a BST.
def search_bst(node, value): if node is None: return False if node.val == value: return True elif value [1] node.val: return search_bst(node.left, value) else: return search_bst(node.right, value)
If the value is less than the current node's value, the search continues in the left subtree.
Fix the error in the base case of the BST search function.
def search_bst(node, value): if node == [1]: return False if node.val == value: return True elif value < node.val: return search_bst(node.left, value) else: return search_bst(node.right, value)
The base case checks if the node is None, meaning the search reached a leaf without finding the value.
Fill both blanks to complete the recursive BST search function correctly.
def search_bst(node, value): if node == [1]: return False if node.val == value: return True elif value [2] node.val: return search_bst(node.left, value) else: return search_bst(node.right, value)
The function first checks if the node is None. Then it compares if the value is less than the node's value to decide the subtree.
Fill both blanks to create a dictionary comprehension that maps node values to their search result in BST.
results = {: search_bst(root, {BLANK_2}}) for {{BLANK_2}} in valuesThis dictionary comprehension creates a dictionary where keys are values from values list and values are the result of searching each value in the BST.