0
0
Data Structures Theoryknowledge~5 mins

Deletion in BST in Data Structures Theory - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a Binary Search Tree (BST)?
A BST is a tree data structure where each node has at most two children. The left child's value is less than the parent node's value, and the right child's value is greater. This property helps in fast searching, insertion, and deletion.
Click to reveal answer
beginner
What are the three main cases when deleting a node in a BST?
1. Node to delete has no children (leaf node).<br>2. Node to delete has one child.<br>3. Node to delete has two children.
Click to reveal answer
beginner
How do you delete a leaf node in a BST?
Simply remove the leaf node from the tree by updating its parent's pointer to null.
Click to reveal answer
intermediate
How do you delete a node with one child in a BST?
Replace the node with its single child by updating the parent's pointer to point to the child, then remove the node.
Click to reveal answer
intermediate
How do you delete a node with two children in a BST?
Find the node's inorder successor (smallest node in right subtree) or inorder predecessor (largest node in left subtree). Replace the node's value with that successor/predecessor's value, then delete the successor/predecessor node which will have at most one child.
Click to reveal answer
What is the first step when deleting a node with two children in a BST?
AFind the inorder successor or predecessor
BRemove the node immediately
CReplace the node with a leaf node
DSwap the node with its parent
If a node to delete has no children, what happens?
AThe entire tree is restructured
BIt is replaced by its child
CIts value is swapped with the root
DIt is simply removed
When deleting a node with one child, what is done?
AThe node is replaced by its child
BThe node is deleted and replaced by null
CThe node is swapped with its sibling
DThe node is left unchanged
Which property must remain true after deleting a node in a BST?
AAll nodes have two children
BLeft child values are less than parent, right child values are greater
CThe tree becomes a linked list
DAll leaf nodes are at the same level
What is the inorder successor of a node in a BST?
AThe largest node in the left subtree
BThe root node
CThe smallest node in the right subtree
DThe node's parent
Explain the three cases of deleting a node in a BST and how each case is handled.
Think about how the tree structure changes in each case.
You got /3 concepts.
    Why is it important to find the inorder successor or predecessor when deleting a node with two children in a BST?
    Consider what happens if you remove the node without replacement.
    You got /3 concepts.