Data Structures & AlgorithmsHard

Why is the standard binary-search probe count for an unsuccessful search about log₂(n), not n?

  1. A. Every element is probed once.
  2. B. Each probe halves the remaining range, so after about log₂ n probes the range is empty.
  3. C. The search always scans the array left to right.
  4. D. Binary search doubles the range each probe.

Correct answer: B. Each probe halves the remaining range, so after about log₂ n probes the range is empty.

Each comparison discards half of the live range, so the range shrinks to nothing in about log₂ n steps, whether or not the key is present.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic