What is the time complexity of binary search with iteration?
O(nlogn)
O(logn)
O(n)
O(n^{2})
Correct Answer: B — O(logn)
Explanation:
(T(n) = T(n/2) + theta(1))
Using the divide and conquer master theorem, we get the time complexity as O(logn).