Back to Academy
searching
Linear Search
Linear Search sequentially checks each element of the list until a match is found or the whole list has been searched. It is the simplest search algorithm and works on both sorted and unsorted data.
Use Cases
- •Small or unsorted datasets
- •When the list is searched only once
- •Simple lookup in unindexed data
Complexity Analysis
| Metric | Best | Average | Worst |
|---|---|---|---|
| Time | O(1) | O(n) | O(n) |
| Space | O(1) | ||
Visualization
Target: 70
10
023
145
270
311
415
5Implementation
Output
Click "Run Code" to see output...