Smallest array forcing 7 probes

Binary search on a sorted array of nn elements needs log2(n+1)\lceil \log_2(n+1) \rceil comparisons in the worst case. What is the smallest array size nn for which the worst case reaches exactly 7 comparisons?

Show hints (2)+
  1. log2(n+1)=7\lceil\log_2(n+1)\rceil = 7 means 6<log2(n+1)76 < \log_2(n+1) \le 7.
  2. Exponentiate: 64<n+112864 < n+1 \le 128, so the smallest nn is at the low end.

Answer

Reveal answer →

64

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: Timed Mental-Math & Sequences, Game-Based Aptitude

Related questions