Question:

In a binary search tree, the worst case time complexity of inserting and deleting a key is:

Show Hint

For an unbalanced binary search tree, both insertion and deletion have a worst case time complexity of $O(n)$, where $n$ is the number of nodes.
Updated On: Sep 25, 2025
  • $O(\log n)$ for insertion and $O(n)$ for deletion
  • $O(n)$ for insertion and $O(\log n)$ for deletion
  • $O(n)$ for insertion and $O(n)$ for deletion
  • $O(\log n)$ for insertion and $O(n)$ for deletion
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation


Step 1: Insertion Complexity.
In a binary search tree (BST), in the worst case, the tree can be unbalanced (e.g., resembling a linked list). In this case, inserting a key will require traversing through all $n$ nodes, making the worst case time complexity for insertion **$O(n)$**.

Step 2: Deletion Complexity.
Similarly, in the worst case, deletion involves traversing the entire tree and potentially restructuring it, which takes **$O(n)$** time.

Step 3: Conclusion.
Thus, the worst case time complexity for both insertion and deletion in a binary search tree is **$O(n)$**.

Was this answer helpful?
0
0

Questions Asked in CUET PG exam

View More Questions