What is the worst-case time complexity of searching in an unbalanced Binary Search Tree?
17 views
- O(log n)
- O(n) (Correct Answer)
- O(n log n)
- O(1)
Explanation
In an unbalanced BST, the tree can degenerate into a linked list (e.g., sorted input). In such cases, searching requires traversing all nodes, leading to O(n) time complexity instead of the optimal O(log n).