A Place for Latest Exam wise Questions, Videos, Previous Year Papers, Study Stuff for MCA Examinations - NIMCET
Previous Year Question (PYQs)
3
In a binary search tree, the worst case time complexity of inserting
and deleting a key is:
Solution
• Insertion: To insert, we first locate the correct position.
This requires searching the tree = height \(h\).
Worst case: tree is skewed (\(h=n\)) → \(O(n)\).
• Deletion: To delete, we also search for the node (\(O(h)\)) and adjust pointers (constant).
Worst case: \(h=n\).
So, time = \(O(n)\).