Mathematics I / Searching and Sorting
Practice question · Sort into groups

Sort each situation by the search method it calls for.

Groups: Linear search · Binary search

Hints
  1. Binary search is only available when the data are already in order.
  2. Sorting first is worth it only if you will search many times.
Show the answer

Linear search: An unsorted list of 30 names, searched once, A stream of readings arriving in no order, checked as it arrives

Binary search: A sorted dictionary of a million words, A sorted array of a billion timestamps, queried constantly

Why

Binary search needs sorted data and pays off most when searches are repeated. For an unsorted list searched once, sorting costs more than simply scanning, the trade-off is between the one-off sorting cost and the number of searches.

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