Searching visualizer

Linear Search

Scan values one by one until the target is found.

Best O(1)Average O(n)Worst O(n)Space O(1)
Example Array
[3, 7, 12, 18, 25, 31, 44, 57, 63]

Visualization

Ready
Ready to scan for 25 from left to right.Target: 25
CurrentVisitedDiscardedFound

Metrics

Comparisons0
Visited0
Progress0%
Time taken0.0s

Pseudocode

  1. linearSearch(arr, target)
  2. for i from 0 to n - 1
  3. check arr[i]
  4. if arr[i] == target
  5. return i
  6. continue to next value
  7. return -1