Computer Science

Time Complexity of Binary Search

Describe the asymptotic search time of binary search.

Time Complexity = O(log n)

Formula Explanation

Binary search repeatedly halves a sorted search interval, giving logarithmic time complexity.

Variables Explained

n = Number of elements in the search space.

Solved Example

Approximately how many halvings are required for 1,024 elements?
Since 2¹⁰ = 1,024, about 10 halvings are required.

Exam Tip

Binary search requires sorted data or a suitably ordered search space.