Growth is what survives
A machine ten times faster multiplies every cost by 1/10 and changes no growth rate. The classification is about the algorithm.
Comparing algorithms means comparing how their costs grow, not their costs at any one size. Constants and lower-order terms vanish; the gap between polynomial and exponential does not.
Core ideas
Growth rate is the property that survives changes of machine, language and constant factor.
A machine ten times faster multiplies every cost by 1/10 and changes no growth rate. The classification is about the algorithm.
3n² + 5n + 100 grows like n²: at n = 1000 the quadratic term is 99.8% of the total.
Polynomial costs scale with hardware; exponential ones do not. 2ⁿ at n = 100 exceeds the number of atoms in the observable universe.
The material
The hierarchy, the numbers behind it, and what a faster machine buys.
At a million elements, an n log n algorithm does about 20 million operations and an n² algorithm does 10¹² — at a billion operations a second, the difference between a fiftieth of a second and about a quarter of an hour. Both are polynomial; the gap is already decisive.
2ⁿ at n = 100 is 1.27 × 10³⁰. At a billion operations per second that is about 4 × 10¹³ years, roughly three thousand times the age of the universe. No hardware improvement addresses this.
If a machine becomes k times faster, the largest instance solvable in fixed time grows by a factor of k for a linear algorithm, by √k for a quadratic one, and by only log₂ k ADDED for an exponential one.
Linear: solving n in time T becomes solving kn. Quadratic: n² in time T becomes kn², so the new size is n√k.
Exponential: 2^n in time T becomes k · 2^n = 2^{n + log₂ k}, so the size increases by log₂ k — an additive constant.
□
A thousandfold speed-up lets a linear algorithm handle a thousand times more data, a quadratic one about 32 times more, and an exponential one ten more items. That is the practical meaning of the polynomial/exponential distinction, and it is why “P, NP and NP-Completeness” draws the line where it does.
So 3n² + 5n + 100 is Θ(n²), and the constant 3 and the additions are discarded — not because they do not exist, but because they do not affect the comparison with an algorithm of a different growth rate.
Constants do matter in practice, and the analysis knows it. An n log n algorithm with a huge constant can lose to an n² one on every input anyone will run, which is why real sort implementations switch to insertion sort for small subarrays. Asymptotic analysis is a tool with known limits, not a complete answer.
Interactive
Counts from running, not from quoting
Method
Growth first; constants only when the growth matches.
The fastest-growing one. Everything else is discarded for the classification.
Consult the hierarchy. A different class settles the comparison for all large n.
Two Θ(n log n) algorithms are separated by their constants, and that requires measurement rather than analysis.
Asymptotics describe large n. If your inputs are always small, the crossover point matters more than the class.
Algorithm A costs 100n log₂ n; algorithm B costs n².
Both facts are true and neither is the whole story. A is asymptotically better and B is better on small inputs, and which matters depends on the data. Real sort implementations resolve exactly this by using insertion sort below a threshold of a few dozen elements.
Determine where 50n log₂ n overtakes n² and say which algorithm you would use for n = 200 and for n = 10⁶. Both answers are defensible and they are different. To check against: 50 log₂ n first drops under n at n = 439.
Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.
No recommendations yet for this lesson.