What Big-O measures
standardbeginnerBig-O describes how the WORST-CASE amount of work grows as input size n grows — not how many seconds a specific run takes. Two functions with the same Big-O can run at very different speeds, and still both be "O(n)".
Think of it as
Big-O is a shape of growth, not a stopwatch reading. A search that always checks every element does the same number of comparisons regardless of what hardware runs it — that comparison COUNT, and how it scales with n, is what O(n) describes. Wall-clock time also depends on hardware, language overhead, and what else is running, none of which Big-O claims to measure.
What we're doing: Confirm that a search checking every element does work that scales linearly with n, regardless of n's actual size.
- 8
- target=-1 never appears, so the search always runs to completion — the comparison count equals n exactly, every time, which is what "O(n)" is claiming: the work scales in direct proportion to n.
10 10
100 100
1000 1000Why this works: The comparison count tracks n exactly (10, 100, 1000) — not some fixed number, and not a number that depends on the computer running it. That is the growth relationship Big-O names; how many real seconds each of those three runs took is a separate question Big-O does not answer.
Remember: O(n) is a claim about how work SCALES with n, in the worst case — never a claim about how many seconds a run takes.
See also: input size and constraints

