1

Assume I have regular binary search, but I change the mid to 2/3*(min+max).
Will the running time change, or remain (log(n))?

I got c1+c2*log(n)/log(3/2).

3
  • Hope you know that the mid is index ... and not the element it self in binary search ! ... Commented Nov 4, 2014 at 20:49
  • Admittedly had to do some back of the napkin work to make sure this wouldn't affect the correctness. Commented Nov 4, 2014 at 20:53
  • just use log(a)/log(b). The performance will reduce. the time complexity will be O(log(n)) Commented Nov 4, 2014 at 20:57

1 Answer 1

3

It'll still be log(n). You'll have a different log base (3/2 instead of 2), but changing a log base is the same as multiplying by a constant.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.