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
intermediate
Why do we use the inorder successor or predecessor when deleting a node with two children in a BST?
Because replacing with inorder successor or predecessor maintains the BST property by ensuring all left subtree values remain smaller and right subtree values remain larger.
Click to reveal answer
beginner
What happens if you delete a leaf node in a BST?
The leaf node is simply removed by setting its parent's pointer to null, as it has no children.
Click to reveal answer
beginner
In Go, what is the base case for the recursive BST delete function?
When the current node is nil (empty), return nil to stop recursion.
Click to reveal answer
Which node do you replace a deleted node with when it has two children in a BST?
✗ Incorrect
Replacing with inorder successor or predecessor keeps the BST properties intact.
What is the first step when deleting a node in a BST?
✗ Incorrect
You must first find the node to delete by traversing the BST.
If a node to delete has only one child, what do you do?
✗ Incorrect
You replace the node with its single child to maintain BST structure.
What is the inorder successor of a node in a BST?
✗ Incorrect
Inorder successor is the smallest node in the right subtree.
What does the BST delete function return when the node to delete is not found?
✗ Incorrect
If node is not found, the function returns the root unchanged.
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 BST deletion handles nodes with zero, one, and two children.
Consider each case separately.
You got /3 concepts.