← back to algorithms

dedicated visualizer

Linear Search

Checks each value in sequence until a match is found or the array ends. This page keeps the runner, chart, and controls focused on a single algorithm so the walkthrough feels calmer than the overview page.

searchingbeginnerbest O(1)worst O(n)space O(1)
sequential scanno preprocessingworks on unsorted data

session controls

Compare this algorithm against a related one, turn on quiz mode, or keep the current state in a shareable URL.

current shareable URL

Copy the URL to preserve this exact dataset, target, compare mode, and quiz state.

browse more

Want a different problem or visual mode? Jump back to the catalog and open another dedicated page.

open catalog

scenario presets

Load a focused input that reveals a specific behavior quickly instead of hand-editing every value first.

dataset controls

Use your own array, randomize a fresh one, or restore defaults. The same dataset is shared by both panels in compare mode.

Enter up to 12 integers. Values are normalized to the range 1–99 for clean visualization.

step 1 / 80% complete

current action

start scan

target 18range 07

index 0

14

still in search range

index 1

3

still in search range

index 2

28

still in search range

index 3

9

still in search range

index 4

41

still in search range

index 5

18

still in search range

index 6

7

still in search range

index 7

25

still in search range

run summary

Finished in 8 steps. 18 is found at index 5.

comparisons

6

current index

5

steps

8

current explanation

Linear search will check each value in order until it finds 18.

simple explanation

Start at the first value and inspect them one by one.

pseudocode

1start at index 0
2inspect the current value
3return if it matches the target
4continue until the array ends

complexity card

best

O(1)

average

O(n)

worst

O(n)

space

O(1)

algorithm notes

intuition

Linear search trades speed for simplicity by never assuming anything about the data.

tradeoffs

  • Works on unsorted input.
  • No setup cost.
  • Slow on large datasets.

when to use it

Use for tiny datasets, streaming data, or one-off checks on unsorted collections.

interview tips

  • Use it as the baseline when comparing against binary search.
  • Mention that it is the only choice if the data is unsorted and cannot be preprocessed.

what I learned building this

typed definitions

One algorithm schema now drives the catalog, counters, pseudocode, notes, and visual modes, which keeps the UI consistent as the lab grows.

replay over mutation

Precomputed steps made it much easier to synchronize explanations, metrics, quiz prompts, and scrubber playback without hidden state drifting out of sync.

portfolio framing

Shareable URL state, compare mode, and responsive layouts mattered as much as the algorithm logic because this page needs to teach clearly and still feel polished as a product.

more in this lane

Want a different take on the same problem family? These stay in the same category but change the strategy.