For most binary search problems, we reduce the array size by half at each iteration. To find the time complexity, we can ask how many times we will have to divide our original array of size (n) until we reach 1.
(x = how many times)
How to Separate x out of the exponent. Logarithms? Take log base 2 on both sides
What power must we raise 2 to get 2^x , that is just x
We need to half the array log n times to get to 1. So thatβs how many times we need to make iterations on an array of size n.
Time Complexity: O(log(n))