Linear Search
Check every slot in order. On average half the array, in the worst case all of it.
Decision · step 2 of 6Array: Linear search, found
Index 0 holds 5, not 2. Move on.
What you will see
One pointer, one comparison per cell; no assumption about order.
Cost
| Best | O(1) |
|---|---|
| Average | O(n) |
| Worst | O(n) |
| Space | O(1) |
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next.
Screen readers: Cells announce index, value and state (current, discarded, found); each step announces the comparison and the resulting range.
Reduced motion: Range and pointer changes snap into place with a short crossfade; discarded cells fade without movement.
Before this
Related
Taught by the same lesson
Array covers these too, in the same run.