Mathematics I / Searching and Sorting
Practice question · Numerical answer

A sorted list holds 64 items. Binary search halves the range at each comparison. In the worst case, how many halvings are needed to reduce it to one item?

Hints
  1. Ask what power of 2 equals 64.
  2. 64, 32, 16, 8, 4, 2, 1, count the arrows.
Show the answer

6

Why

26=642^{6} = 64, so six halvings. Linear search on the same list could need 64 comparisons, the same data, an order of magnitude apart, purely from exploiting the ordering.

Read the lesson: Searching and Sorting →

Practise Searching and Sorting

The app has 6 more questions on this lesson, and keeps your place in the course. Mathematics I is free to start.

More questions on Searching and Sorting