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). 2. Node to delete has one child. 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
intermediate
Why do we use the inorder successor or predecessor when deleting a node with two children in a BST?
Because the inorder successor or predecessor maintains the BST property after replacement, ensuring the tree remains correctly ordered.
Click to reveal answer
beginner
What happens if you delete a leaf node in a BST?
The leaf node is simply removed, and its parent's pointer to it is set to null.
Click to reveal answer
beginner
How do you delete a node with only one child in a BST?
Replace the node with its single child by updating the parent's pointer to point to the child, then delete the node.
Click to reveal answer
Which node do you replace a node with when deleting a node with two children in a BST?
ARoot node
BInorder successor or inorder predecessor
CAny leaf node
DRandom node in the tree
✗ Incorrect
The inorder successor or predecessor maintains the BST property after deletion.
What is the first step when deleting a node in a BST?
AFind the node to delete
BReplace the node with root
CDelete the entire tree
DSwap left and right children
✗ Incorrect
You must first find the node to delete before handling its removal.
If a node to delete has no children, what do you do?
AReplace it with inorder successor
BReplace it with its child
CDo nothing
DRemove the node and set parent's pointer to null
✗ Incorrect
A leaf node can be removed directly by updating the parent's pointer.
When deleting a node with one child, what happens to the child?
AIt becomes the root
BIt is deleted too
CIt replaces the deleted node
DIt is moved to the leaf
✗ Incorrect
The single child replaces the deleted node to maintain the BST structure.
Which traversal helps find the inorder successor in a BST?
ARight subtree's minimum node
BRight subtree's maximum node
CLeft subtree's maximum node
DLeft subtree's minimum node
✗ Incorrect
The inorder successor is the smallest node in the right subtree.
Explain the steps to delete a node with two children in a BST.
Think about maintaining BST order after deletion.
You got /4 concepts.
Describe how deleting a node with one child differs from deleting a leaf node in a BST.
Focus on how the parent's pointer changes.
You got /3 concepts.
Practice
(1/5)
1. What happens when you delete a leaf node (a node with no children) from a Binary Search Tree (BST)?
easy
A. The node is replaced by its right child.
B. The entire tree is restructured to maintain BST properties.
C. The node is simply removed and its parent's pointer is set to null.
D. The node is replaced by its left child.
Solution
Step 1: Understand leaf node deletion
A leaf node has no children, so removing it does not affect other nodes.
Step 2: Update parent's pointer
The parent's pointer to this node is set to null, effectively removing the node.
Final Answer:
The node is simply removed and its parent's pointer is set to null. -> Option C