What are the worst-case complexities of insertion and deletion of a key in a binary search tree?
View worked solution
Answer: B
In a standard Binary Search Tree (BST) of nodes, the time complexity of search, insertion, and deletion operations is directly proportional to the height of the tree.
In the worst-case scenario, the BST is highly unbalanced (skewed), where each node has at most one child (resembling a singly linked list). In this case, the height of the tree is .
- Insertion: To insert a new key, we must traverse from the root to find the appropriate empty spot. In a skewed tree, this traversal can go all the way to the deepest leaf, taking steps.
- Deletion: To delete a key, we first locate the node (which takes up to steps). If the node has two children, we must also find its inorder successor or predecessor, which can take another traversal. Thus, the overall worst-case complexity remains .
Therefore, the worst-case complexities for both insertion and deletion are , making Option B the correct choice.
Free practice · Your answers on this page are not saved.
