The interactive player is loading. If it does not appear, you can still read the explanation below.
How it works
Linear search checks values from left to right. It works on unsorted arrays and stops at the first match. If every value has been checked without a match, the target is absent.
Watch the index pointer and the dimmed cells that have been ruled out. A match at the beginning takes one comparison; a missing target requires checking every value. Worst-case time is O(n), best-case time is O(1) for a nonempty array, and extra algorithm space is O(1). The visualization stores steps for replay separately.
Duplicates are allowed: this version returns the first matching index. An empty array has no match and needs no comparisons.