Recall & Review
beginner
What are the three main cases to consider when deleting a node in a Binary Search Tree (BST)?
1. Node to delete is a leaf (no children).<br>2. Node to delete has one child.<br>3. Node to delete has two children.
Click to reveal answer
intermediate
In BST deletion, how do you handle deleting a node with two children?
Replace the node's value with its inorder successor (smallest value in right subtree) or inorder predecessor (largest value in left subtree), then delete that successor/predecessor node.
Click to reveal answer
beginner
What is the inorder successor in a BST?
The node with the smallest value in the right subtree of the current node.
Click to reveal answer
intermediate
Why do we replace a node with its inorder successor or predecessor when deleting a node with two children?
Because it maintains the BST property by ensuring all left subtree nodes are smaller and all right subtree nodes are larger than the replaced node.
Click to reveal answer
beginner
What happens if you delete a leaf node in a BST?
You simply remove the leaf node by setting its parent's pointer to null.
Click to reveal answer
Which of the following is NOT a case to consider when deleting a node in a BST?
✗ Incorrect
In a BST, a node can have at most two children, so 'three children' is not a valid case.
When deleting a node with two children, which node is commonly used to replace it?
✗ Incorrect
The inorder successor (smallest node in right subtree) is used to replace the deleted node to maintain BST properties.
What is the inorder successor of a node in a BST?
✗ Incorrect
The inorder successor is the smallest node in the right subtree of the node.
If a node to delete has only one child, what is the deletion process?
✗ Incorrect
The node is removed and its single child is linked directly to the node's parent.
What happens to the BST property after deleting a node and replacing it with its inorder successor?
✗ Incorrect
Replacing with inorder successor maintains the BST property because the successor fits correctly in the tree order.
Explain the steps to delete a node with two children in a BST.
Think about how to keep the tree ordered after deletion.
You got /4 concepts.
Describe how deleting a leaf node differs from deleting a node with one child in a BST.
Consider the connections between nodes.
You got /4 concepts.