algo·visual

Linear Search

Searching
avgO(n)worstO(n)spaceO(1)
19
64
33
71
60
47
82
27
53
10
53
11
59
25
20
95
70
13
17
8
target 25

Look for 25 from the left

1 / 16
Size20
Distribution
Custom values2 to 150 whole numbers, each 1 to 999

seed 8

Target

How it works

Checks every element from left to right until it finds the target or runs out of array. It works on unsorted data without any preparation, but it may look at all n elements.

Complexity

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

Search algorithms

Jump to any algorithm or page