Mathematics I / Searching and Sorting
Practice question · Fill in the blanks

Complete the reason binary search is fast.

Binary search is fast because each comparison ______.

Word bank: removes one element from consideration · removes half of the remaining elements · sorts part of the list · doubles the range being searched

Hints
  1. Compare with linear search, which eliminates exactly one candidate per comparison.
  2. That is why the cost is a count of halvings.
Show the answer

Binary search is fast because each comparison removes half of the remaining elements.

Why

Each comparison discards half the remaining candidates, so the number of comparisons is the number of halvings, logarithmic. Linear search eliminates one per comparison, which is why its cost is proportional to n.

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