Linear Search
The most basic search method: checks every element in order from the start of the array until it finds the target.
01Linear Search
Explore How It WorksStarting linear search. We scan the array from the front, one by one, to find the target 34.
The first value, 45, is not the target. Step one slot to the right.
The next value, 12, isn't it either. Keep moving right.
89 is not the target either. Scanning from the front leaves nothing to skip.
The fourth value is 34 — a match. The search stops here.
Search complete · 34 sits at index 3. It works even on unsorted data, but slows down as the array grows.
02 Understand It Simply
For EveryoneCompares values one at a time from the front. The data need not be sorted, but the worst case looks at all of it.
Compares elements one by one from the front to find the target.
It doesn't need sorted data, but it's slow at O(n).
- –Small unsorted data
- –one-off lookups
03 Python Implementation
A clean, readable reference implementation of the core logic of Linear Search.
04 Frequently Asked Questions
FAQWhat is Linear Search?+
The most basic search method: checks every element in order from the start of the array until it finds the target.
What is the time complexity of Linear Search?+
The time complexity of Linear Search is O(n). Follow the step-by-step visualization to see exactly why.
Where is Linear Search used?+
Small unsorted data, one-off lookups.
What's a simple analogy for Linear Search?+
Compares values one at a time from the front. The data need not be sorted, but the worst case looks at all of it.
