AlgoScope

Linear Search

Check every slot in order. On average half the array, in the worst case all of it.

Searching, algorithm, beginnerAlso called Array Search
Index 0 holds 5. That does not match.501142238435i5 > 2
Index 0 holds 5. That does not match.501142238435i5 > 2

Array: Linear search, found

Decision, step 2 of 6

Index 0 holds 5, not 2. Move on.

How array works

Cost

Best
O(1)
Average
O(n)
Worst
O(n)
Space
O(1)

Before this

Leads to

Topics that need this one first.

Taught by the same lesson

Array covers these too, in the same run.