Linear Search Visualizer
Watch how Linear Search checks each element sequentially until the target is found or the array ends.
Time: O(n)
Space: O(1)
No Prerequisites
Sequential Access
0
45
1
23
2
78
3
12
4
67
5
34
6
89
7
56
8
23
9
91
Target: 23 | Comparisons: 0 | Step: 1 of 0
Current Step:
Click Start to begin Linear Search visualization
Linear Search
Time Complexity:O(n)
Space Complexity:O(1)
Best Case:O(1)
Worst Case:O(n)
Color Legend
Currently Checking
Target Found
Already Checked
Not Yet Checked
Python Implementation
def linear_search(arr, target):
    found_indices = []
    
    for i in range(len(arr)):
        if arr[i] == target:
            found_indices.append(i)
    
    return found_indices if found_indices else -1
# For finding first occurrence only:
def linear_search_first(arr, target):
    for i in range(len(arr)):
        if arr[i] == target:
            return i
    return -1Real-world Applications
- • Searching unsorted data collections
 - • Finding all occurrences of an element
 - • Small dataset searches where simplicity matters
 - • Searching linked lists (no random access)
 - • Finding patterns in text processing
 - • Initial validation and testing scenarios