BEGINNER · 10 MIN · FREE LESSON
Linear search
Explore linear search through a visual, step-by-step model.
Loading interactive lesson…
BEGINNER · 10 MIN · FREE LESSON
Explore linear search through a visual, step-by-step model.
Loading interactive lesson…
Enter {"values":[1,2,3,4,5],"target":4}. All searches except linear search require ascending values.
Search for 4.
Inspect values one by one; an absent target requires visiting every position.
Measured reads + comparisons, seed 42. Plotted sample sizes respect each lesson’s explicit input limits.
Keyboard: Space play/pause · ←/→ step · R restart · 1–5 speed. Reduced motion disables transitions.
Look through a shuffled pile of letters until you find the address you need.
Find it one value at a time. Change the target and input in the JSON input editor.
Predict the next comparison or retained interval, then use the real trace to check the move.
The best case is a first-position match. An absent target needs n comparisons, so average and worst cases are linear.
Follow the active stage in JavaScript, Python, Java or C++. Search intervals and probe variables stay visible beside the animation.
Use it on unsorted or tiny sequences, or when sequential access is the natural interface.
Do not claim logarithmic time without a sorted-search invariant. This implementation returns the first matching index.
Answer the questions below, then try absent targets, duplicates and boundary positions.
MAKE IT STICK
Progress saves on this device and merges with your account after sign-in.
0 / 5000 · Saved on this device; synced when signed in.