AiTechWorlds
AiTechWorlds
Animate Linear Search scanning each element until it finds the target, with synced code and comparison counter.
def linear_search(a, target):
for i, x in enumerate(a):
if x == target:
return i
return -1Linear Search scans elements one by one from the start until it finds the target or reaches the end. It works on any array, sorted or not.
| Best | O(1) |
| Average | O(n) |
| Worst | O(n) |
| Space | O(1) |
| Requires sorted | No |
The Linear Search Visualizer animates how Linear Search works: it scans elements one by one from the start until it finds the target or reaches the end. Linear Search runs in O(n) average and worst case, O(1) best case, uses O(1) space, and works on any array — sorted or unsorted.
Set a target
Type the value to search for, or click New Array to randomize the data and target.
Play the animation
Press Play to watch each index checked (yellow) until the target turns green.
Step and scrub
Use Step Forward/Back or the timeline to inspect each comparison.
Read the synced code
The highlighted pseudocode line tracks the scan; switch tabs for C++, Java, Python, or JavaScript.
100% Private — No Server Required
All processing happens directly in your browser. No data is uploaded, stored, or transmitted to any server.
Last reviewed on June 14, 2026 by the AiTechWorlds Tools Team. All processing runs locally in your browser.