15
0
8
1
23
2
42
3
4
4
16
5
99
6
7
7
Target42
Checking Index-
Checks Made0

The Simple Scanner

Linear Search is the most basic way to find something. It's like looking for your keys. You check one place, then the next, then the next...

First Look

We start at the beginning (Index 0). Is 15 equal to 42? No. We move on.

Keep Walking

We check Index 1. Is 8 equal to 42? Nope. Still haven't found it.

Getting Closer?

Index 2 has 23. Still not 42. With Linear Search, we have no shortcuts. We MUST check every single box until we get lucky.

Found It!

Index 3! We found 42. Success! But notice, we had to check 4 items to get here. If 42 was at the end, we would have checked everyone.

The Cost (O(n))

This simple method is O(n) or 'Linear Time'. If you have 100 items, you might have to check 100 times. Simple, but slow for big lists!

Simple but Essential.

Sometimes, you just have to check everything.

AlgoAnimator: Interactive Data Structures