x

Searching and sorting at a glance

Two-panel comparison of searching for 18: linear search checks each item in an unsorted list until index 4, and binary search halves a sorted list to find index 4

A search finds a target value in a list, while a sort rearranges the list into order. The diagram shows the key search contrast: linear search checks one by one, while binary search throws away half of a sorted range each step.

Searching and sorting algorithms Lesson