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 value into the BST correctly.
if (value [1] node.value) { node.left = insert(node.left, value); } else { node.right = insert(node.right, value); }
Values less than the node go to the left subtree; others go right.
Fix the error in the BST search condition to find a value.
if (node.value [1] value) { return search(node.left, value); } else if (node.value === value) { return node; } else { return search(node.right, value); }
If the node's value is greater than the target, search left subtree; else right.
Fill both blanks to create a BST property check function.
function isBST(node) {
if (!node) return true;
if (node.left && node.left.value [1] node.value) return false;
if (node.right && node.right.value [2] node.value) return false;
return isBST(node.left) && isBST(node.right);
}Left child must be less than node (so fail if left >= node). Right child must be greater than node (fail if right <= node).
Fill all three blanks to create a function that collects BST values in order.
function inorderTraversal(node, result = []) {
if (!node) return result;
inorderTraversal(node.[1], result);
result.push(node.[2]);
inorderTraversal(node.[3], result);
return result;
}Inorder traversal visits left subtree, then node value, then right subtree.
