In a binary search algorithm, what is the time complexity for searching an element in a sorted array of n elements?

  • O(1)
  • O(log n)
  • O(n)
  • O(n^2)
The time complexity of a binary search algorithm is O(log n), as it repeatedly divides the search interval in half, resulting in a logarithmic time complexity. This makes it more efficient than linear search algorithms (O(n)).
Add your answer
Loading...

Leave a comment

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