What is the worst-case time complexity of searching for an element in an unbalanced Binary Search Tree containing N nodes?
Options
- A. O(1)
- B. O(log N)
- C. O(N)
- D. More than one of the above
- E. None of the above
Quiz Practice:
C. O(N)
The worst-case search complexity of a Binary Search Tree is O(N) when the tree becomes completely or nearly skewed. In such a tree, it can behave like a linked list, requiring the search to examine many nodes. A balanced BST has height approximately O(log N), giving logarithmic search. Examples of self-balancing BSTs include AVL trees and Red-Black trees.