Complete the code to check if a value should go to the left subtree in a BST.
if value [1] node.Value { // go left }
In a BST, values less than the current node go to the left subtree.
Complete the code to insert a new node in the BST when the value is greater.
if value [1] node.Value { node.Right = insert(node.Right, value) }
Values greater than the current node go to the right subtree in a BST.
Fix the error in the BST search condition to correctly find a value.
if node == nil || node.Value [1] value { return node }
We return the node when its value equals the searched value.
Fill both blanks to create a BST property check for left and right children.
if node.Left != nil && node.Left.Value [1] node.Value { return false } if node.Right != nil && node.Right.Value [2] node.Value { return false }
Left child must be less than current node, so left.Value < node.Value is true; violation if left.Value >= node.Value.
Right child must be greater than current node, so right.Value > node.Value is true; violation if right.Value <= node.Value.
Fill all three blanks to build a dictionary comprehension that maps node values to their depths if depth is greater than 1.
depthMap := map[int]int{}
for node, depth := range nodes {
if depth [1] 1 {
depthMap[[2]] = [3]
}
}We check if depth is greater than 1, then map node to depth in the dictionary.