In a binary search tree, the worst case time complexity of inserting and deleting a key is:
Step-by-step Solution:
For a Binary Search Tree (BST), time complexities depend on the height \(h\) of the tree. - In the worst case (when the BST is completely unbalanced, e.g. degenerates into a linked list), the height \(h = n\). - Most basic BST operations (search, insertion, deletion) take time proportional to the height, i.e. \(O(h)\).
Insertion: We search from the root to the correct leaf position and insert — cost \(O(h)\). In worst case \(h = n\) ⇒ insertion \(\;=\; O(n)\).
Deletion: We locate the node (cost \(O(h)\)) and may need to find its in-order successor/predecessor (again up to \(O(h)\)) and adjust pointers — overall \(O(h)\). In worst case \(h = n\) ⇒ deletion \(\;=\; O(n)\).
✅ Correct Answer: (C) \(O(n)\) for insertion and \(O(n)\) for deletion