8
0
15
1
23
2
31
3
42
4
49
5
56
6
63
7
71
8
79
9
86
10
94
11
AlgoPlus//searching / linear search
Read the theory

Linear Search · Scanning Beam

A photonic beam sweeps left-to-right until the target resonates.

Stability
In-Place
Space Complexity
Avg Time
Target
Legend
Element being checked
Target found
AI Tutor Workspace
In a nutshell
Linear search is the most basic way to find something: start at the first element and check each one in turn until you hit the target or run off the end. It needs no setup and works on any list — sorted or not — but on average it looks at half the elements and, in the worst case, all of them, so it slows down in step with the list's size.
Ready
Press play to begin the cinematic walkthrough.
A scanning beam sweeps across the array, checking each element until the target is found.
Key terms
Go deeper in the lesson
Read the full theory, intuition & complexity for Linear Search · Scanning Beam.
Code Simulator
1
def linear_search(arr, target):
2
    for i in range(len(arr)):
3
        if arr[i] == target:
4
            return i  # Found
5
    return -1  # Not Found
Why Python? · Readable first, fast second

Dynamically typed and interpreted — every comparison and swap is dispatched by the interpreter at run time, so tight loops run roughly 10–100× slower than compiled C/C++. Unbeatable for learning the idea with the least code; not what you reach for when the inner loop is the bottleneck.