Ryan Knopp
← Back to Searches

Linear Search

Linear search is the one you already do by hand. Start at the front, look at each value in turn, and stop the moment you hit the one you want. It does not care whether the data is sorted, which is exactly why it is the honest baseline: no setup, no assumptions, it just looks at everything until it gets lucky or runs out of list.

That also makes it the slow one. Best case the target is right at the front and you are done in a single comparison. Worst case it is last, or not there at all, and you have looked at every element to find that out. On average you check about half of them, so the work grows straight in line with the size of the list. That is the O(n) wall the sorted searches exist to get around.

Hit Play to watch it scan, or use Next and Back to step one comparison at a time. It opens on real words, so type any word into the search box to hunt for it in the paragraph, or leave the box empty and let the Target menu pick one that is present or missing. Data switches between words and numbers, and New array deals a fresh set.