Following is a simple binary search implementation:
Time complexity:
\text{Let } n &\text{ be the number of elements in the array.} \\ \text{At each step, the size of the search space is halved,} &\text{ so the recurrence relation is:} \\ T(n) &= T\left(\frac{n}{2}\right) + O(1) \\ \text{After } k \text{ iterations, the search space becomes } \frac{n}{2^k} &\text{ elements.} \\ \text{We stop when there is only one element left, i.e.,} &\text{ when } \frac{n}{2^k} = 1. \\ n &= 2^k \\ \log_2{n} &= k \\ \text{Therefore, the time complexity } T(n) &\text{ is:} \\ T(n) &= O(\log_2{n}) \end{align*} $$