Big-O notation
A way of describing how much slower something gets as you give it more data, ignoring the specific machine and the exact number of seconds.
Think of it likeSaying a journey “takes twice as long if you double the distance” rather than “takes 43 minutes”. The first statement is still true on a different day in a different car.
You are not measuring seconds. Seconds depend on your laptop, on what else is running, and on the weather inside the processor. Big-O describes the shape of the growth, which is the part that stays true everywhere.
The handful you actually need, from best to worst. O(1): constant — the same time no matter how much data, like fetching item number 500 from a list. : grows extremely slowly, because each step throws away half of what is left; going from a thousand items to a million adds only about ten steps. O(n): grows in step with the data — reading every item once. O(n log n): the realistic best for sorting things. O(n²): a loop inside a loop, where ten times the data means about a hundred times the work.
The reason this matters is that the difference is not academic. Something O(n²) that takes one second on 1,000 records takes about three hours on 100,000. That is the shape of a dashboard which worked fine at launch and fell over the day the customer table grew.
There are two related notations you will see. Big-Omega describes a lower bound — the best case. Big-Theta describes a tight bound, used when best and worst are the same shape. In practice people say Big-O and mean the worst case, and that convention is fine to adopt.
One caveat worth holding onto: Big-O ignores constant factors, so an O(n) method can lose to an O(n²) one on small inputs. It describes what happens as things get large, not what is fastest on ten items.
Where you meet it in real softwareDeciding whether a report generator will still work next year, choosing between two libraries, and explaining in a code review why an approach is unacceptable.