Binary Search
- Count the number of visits to search an sorted array of size n
- We visit one element (the middle element) then search either
the left or right subarray
- Thus: T(n) = T(n/2) + 1
- If n is n/2, then T(n/2)
= T(n/4) + 1
- Substituting into the original equation:
T(n) = T(n/4) + 2
- This generalizes to: T(n) = T(n/2k)
+ k