ArticlesCost

Cost

Big O

A way to talk about how the work grows as the input grows, ignoring constant factors and one laptop's speed.

Big O is a shared way to say cheap before you argue about a structure. It answers one question: if the input gets larger, how does the number of steps grow?

You ignore the speed of a particular machine, and the small bookkeeping every language adds. An O(n) scan that touches each value once does about twice the work for twice the input. An O(n²) solution, often a loop inside a loop, grows much faster than that. Constant factors still matter when you ship the code. They do not change which of those two shapes wins once the input is large.

You do not need a formal proof to use this. Name the loops. One pass over the input is linear. A pass that, for each index, scans the rest of the array is quadratic. Nested loops multiply. When you can say the cost out loud, you can decide whether the solution is allowed to stay.