Linear Search Visualizer
Visualize how linear search algorithm works step by step
Linear Search Visualization
Array Bar Chart
Currently Checking
Found
Already Checked
Not Found
Not Yet Checked
Current Array:
[]
Searching for:
0
Array Controls
Search Target
Search Controls
Algorithm Analysis
Time Complexity
Best Case:
O(1)
Average Case:
O(n)
Worst Case:
O(n)
Space Complexity
Auxiliary Space:
O(1)
Current Statistics
Array Size:
0
Target Value:
0
Comparisons:
0
Search Progress:
0%
Result:
Not Found
Algorithm Properties
Characteristics:
- • Sequential: Checks elements one by one from start to end
- • In-place: Uses constant extra space
- • Simple: Easy to understand and implement
- • Works on unsorted data: No need for pre-sorting
When to Use:
- • Small datasets
- • Unsorted arrays
- • When simplicity is more important than efficiency
- • Educational purposes
- • When target is likely to be at the beginning
When NOT to Use:
- • Large datasets
- • Sorted arrays (use binary search instead)
- • Performance-critical applications
- • When target is likely to be at the end
How Linear Search Works
1. Start: Begin at the first element (index 0).
2. Compare: Check if current element equals the target.
3. Found: If equal, return the current index.
4. Continue: If not equal, move to the next element.
5. Repeat: Continue until target is found or array is exhausted.
6. Not Found: If entire array is searched without finding target, return -1.
Performance Comparison
Linear Search:
- • Time: O(n)
- • Space: O(1)
- • Works on unsorted data
- • Simple implementation
Binary Search:
- • Time: O(log n)
- • Space: O(1)
- • Requires sorted data
- • More complex implementation