Binary search invariant

Binary search on a sorted array of n=63n = 63 elements does how many comparisons in the worst case? (Each step halves the search range.)

Show hints (2)+
  1. Worst case is $\lceil \log_2(n+1) \rceil$.
  2. $n+1 = 64 = 2^6$.

Answer

Reveal answer →

6

Want the full step-by-step worked solution? It's part of Premium — along with a worked solution for every question in the bank.

Asked at: Optiver, IMC

Related questions