Linear Search
noun
say it: “LIN-ee-er SURCH” /ˈlɪniər sɝːtʃ/
A way of finding an item by checking each one in turn, from the first, until it turns up or the items run out.
What is linear search?
Linear search checks each item in turn, from the first, and stops at the first match, like opening gym lockers one after another until you find your bag. It gives back the item's position, or -1 when the item isn't there. It works on a list in any order, and it is O(n): twice the items, twice the looks in the worst case.
In a sentence
- “The playlist wasn't sorted, so the app used a linear search and read every title until it found Slow Rain.”
Level: Apprentice · More Data Structures terms at this level
Updated