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 a given 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 in a BST?
To maintain the BST property where left subtree nodes are smaller and right subtree nodes are larger than the node, ensuring the tree remains correctly ordered after deletion.
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, as it has no children.
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 the right subtree) is commonly used to replace a node with two children.
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
If the node has one child, replace the node with its child to maintain BST structure.
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 node's position.
Explain the steps to delete a node with two children in a Binary Search Tree.
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 number of children and how the tree links change.
You got /4 concepts.