What is the time complexity of searching for an element in a binary search tree (BST)?

  • O(1)
  • O(log n)
  • O(n log n)
  • O(n)
The time complexity of searching for an element in a binary search tree (BST) is O(log n), where n is the number of nodes in the tree. This is because in a balanced BST, each comparison made during the search reduces the search space by half, leading to logarithmic time complexity.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *