What is the time complexity of the Binary Search algorithm on a sorted array of size n?
Show answer
O(log n)
Binary search is a divide-and-conquer algorithm that halves the search space in each step, leading to a logarithmic number of comparisons.
Also asked as:
- What is the Big O time complexity of performing a binary search on a sorted array of n elements?