Complete the code to return the minimum value in a BST.
def find_min(root): current = root while current.[1] is not None: current = current.left return current.val
The minimum value in a BST is found by going as far left as possible.
Complete the code to handle the case when the BST is empty.
def find_min(root): if [1] is None: return None current = root while current.left is not None: current = current.left return current.val
We check if the root itself is None to handle empty trees.
Fix the error in the code to correctly find the minimum value in the BST.
def find_min(root): current = root while current.left is not None: current = current.[1] return current.val
To find the minimum, we must move left, not right.
Fill both blanks to create a dictionary of node values and their depths for nodes with values less than 10.
def collect_nodes(root): result = {} def helper(node, depth): if node is None: return if node.val [1] 10: result[node.[2]] = depth helper(node.left, depth + 1) helper(node.right, depth + 1) helper(root, 0) return result
We check if node.val is less than 10 and use node.val as the key in the dictionary.
Fill both blanks to create a dictionary of uppercase node values and their depths for nodes with values greater than 5.
def collect_upper_nodes(root): result = {} def helper(node, depth): if node is None: return if node.val [1] 5: result[node.val.[2]()] = depth helper(node.left, depth + 1) helper(node.right, depth + 1) helper(root, 0) return result
We check if node.val is greater than 5, use the 'upper' method to convert the value to uppercase, and call it with parentheses.
