Lets look at the worst-case behaviour. Search continues from 0, 1, 2, 4, 8.... lets say n is 2^k for some k >= 0. In the worst-case we might end up searching until 2^k and realise we overshot the target.
Now we know that target can be in 2^(k - 1) and 2^k. The number of elements in that range are 2^(k - 1) (think a second. ).
The number of elements that we have examined so far is O(k) which is O(logn). The following recurrence summarises it.
Lets look at the worst-case behaviour. Search continues from 0, 1, 2, 4, 8.... lets say n is 2^k for some k >= 0. In the worst-case we might end up searching until 2^k and realise we overshot the target.
Now we know that target can be in 2^(k - 1) and 2^k. The number of elements in that range are 2^(k - 1) (think a second. ).
The number of elements that we have examined so far is O(k) which is O(logn). The following recurrence summarises it. T(n) = T(n/2) + O(logn) = T(n/4) + c1log(n/2) + c2logn ((all logs are base 2.)) .
. .. = O((logn)^2) So the worst-case complexity of this algorithm is quadratic of URL1 maybe not the tightest bound but it is a good upper bound.
Because you're not doing log(n) comparisons for each iteration; you're doing fewer and fewer as time goes on... I'm not sure what that is, though... – Mehrdad Mar 11 at 22:58 yes. You are right! First iteration takes log(n), second iteration takes log(n/2) ...... summing it gives tighter bound.
Agreed! I gave upper bound... I'm not sure if summing tightly changes complexity asymptotically. – Srikanth Mar 16 at 18:40 Oh... hm... that means we have log(n) + log(n) - log(2) + log(n) - log(3) ... and yeah, yours is a pretty nice bound; thanks!
– Mehrdad Mar 16 at 18:50.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.