Mathematics I / Searching and Sorting
Practice question · Numerical answer

A sorted list holds 1,048,576 items, which is 2 to the power 20. How many halvings does binary search need to narrow it to a single item?

Hints
  1. The exponent in the power of 2 is the answer.
  2. Each halving reduces the exponent by exactly one.
Show the answer

20

Why

Twenty halvings. A million items cost 20 comparisons rather than a million, and doubling the data to two million would add just one more.

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