Complete the code to check if the current node is null before deletion.
if (root [1] null) { return root; }
We use '==' to check if root is null before proceeding.
Complete the code to recursively delete a node from the left subtree.
if (key < root.val) { root.left = root.left [1] deleteNode(root.left, key); }
We assign the result of deleteNode to root.left to update the subtree.
Fix the error in the code to find the minimum value node in the right subtree.
Node minNode = root.right; while (minNode.[1] != null) { minNode = minNode.left; }
We traverse right subtree's left children to find the minimum node, so we check minNode.left != null.
Fill both blanks to replace the node's value and delete the inorder successor.
root.val = minNode.[1]; root.right = deleteNode(root.right, [2]);
We replace root's value with minNode.val, then delete minNode.val from right subtree.
Fill all three blanks to handle node deletion with one or no child.
if (root.left == null) { return root.[1]; } else if (root.right == null) { return root.[2]; } // Node with two children handled elsewhere return root; // End of deleteNode function // [3]
If left child is null, return right child; if right child is null, return left child. The last blank is a comment marking function end.
