ArticlesCost

Cost

Linear time

One pass over the input. Twice the data means about twice the work, including a linear search.

Linear time means the work tracks the length of the input. Summing an array, counting values below a limit, or scanning until you find a target are all one trip from the start toward the end. Twice as many elements, about twice as many steps.

Linear search is the plain version of that scan. You check index 0, then 1, then 2, and you stop early only when you are lucky. If the value is missing, you have looked at everything. That is the honest cost, and it is often the right one. Not every problem has a faster shape hiding inside it.

The habit to retire is doing that pass more times than the problem needs. If each element is handled with a constant amount of work, you are in O(n). If each element starts another scan of the rest of the array, you have left linear time behind.