The leaf node case and the single-child case came out fine.
Start by defining the BST property and the three deletion cases: leaf, one child, two children. For the two-child case, explain replacing the node with its in-order successor (or predecessor) and recursively deleting that successor. Emphasize maintaining BST invariants and discuss time complexity.
Pro tip: Mention that using the in-order predecessor instead of successor can reduce tree height in some cases, and note that deletion in a balanced BST is O(log n) but O(n) in the worst case.
State that a BST maintains left < root < right, and deletion must preserve this property. The goal is to remove a node while keeping the tree valid.
Simply remove the node by setting its parent's pointer to null. This is the simplest case.
Replace the node with its only child by updating the parent's pointer to point to the child. The subtree remains valid.
Find the in-order successor (smallest node in right subtree) or predecessor (largest in left subtree). Copy its value to the node, then recursively delete the successor/predecessor from its original position.
Discuss time complexity: O(h) where h is height, O(log n) for balanced, O(n) for skewed. Mention edge cases like deleting root or node not found.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.