i found the recursive relation which is T(n) = 1 + t(n/2)(adsbygoogle = window.adsbygoogle || []).push({});

after a couple of substitutions i found the pattern which is T(n) = 2^{i-1}+ T(n/ 2^{i})

i chose i = log2 n and then when i plugged it in i got

T(n) - 2^{log2(n -1)}+ T(1)

but doesnt the first part simplify to n-1?

the complexity of binary search is O(logn)

where did i mess up?

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Binary search complexity

**Physics Forums | Science Articles, Homework Help, Discussion**