CMD Guide
HomeDSAFoundations

Functions and Their Growth Rates

Functions and Their Growth Rates

Every algorithm's cost is a function: feed it the input size n and it returns the number of basic operations. This page is the field guide to those functions — the handful of growth classes you meet again and again, exactly how fast each one explodes in raw numbers, and the dominance rules that stack them in an order that never reverses. Knowing the definition of Big-O tells you how to write a bound; knowing the zoo tells you what a bound means the instant you see it.

The formal ∃c,n0 definition lives on Big-O Notation, and the method for deriving a bound from code is on Understanding Time Complexity. Here we take the classes as given and study their behaviour.

The zoo, in raw operation counts

Abstract rankings do not land until you see the numbers. Here is the actual operation count for each class at four input sizes:

classn=10n=100n=1000n=1,000,000
O(1) constant1111
O(log n)3.36.61020
O(n)101001,000106
O(n log n)336649,966~2×107
O(n2)10010,0001061012
O(2n)1,024~1030~10301beyond astronomical

Read the last two rows. At a million items O(n2) is a trillion operations (minutes to hours); O(2n) passes the number of atoms in the universe by n = 300. Meanwhile O(log n) crawls from 3 to 20 across the entire table — six orders of magnitude of input for a 6× rise in work. That flatness is why logarithmic operations feel free.

Dominance: the order that never reverses

For large n the classes stack in a fixed hierarchy, and two rules generate it:

The crossover that makes rule two concrete. "My algorithm is only polynomial — degree 10, sure, but polynomial" sounds safer than exponential. Is it? Compare 2n against the enormous polynomial n10. Set them equal: 2n = n10 ⇒ n·ln2 = 10·ln n ⇒ n/ln n = 10/ln2 ≈ 14.4. Solving gives n ≈ 59: below 59, the degree-10 polynomial is actually the larger count; at n = 59 the exponential overtakes it and never looks back (259 ≈ 5.8×1017 vs 5910 ≈ 5.1×1017). So even a grotesque polynomial is dominated by a modest exponential past a small threshold — the hierarchy is not a suggestion.

Reading a growth curve like an engineer

On an ordinary linear plot (above, and the interactive) the curves tangle near the origin — small n hides everything. The professional trick is the log-log plot: plot log T(n) against log n. Then any power law T = nk becomes a straight line whose slope is exactly k (because log(nk) = k·log n). Linear is a line of slope 1, quadratic slope 2 — you can read the exponent straight off the chart, and it is exactly how you turn benchmark timings into an empirical growth class. Exponentials refuse to straighten: they still curve upward even on log-log, which is the instant visual tell that you are not looking at a polynomial.

Pitfalls specific to comparing growth rates

Key takeaways

🤖 Don't fully get this? Learn it with Claude

Stuck on Functions and Their Growth Rates? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **Functions and Their Growth Rates** (DSA) and want to truly understand it. Explain Functions and Their Growth Rates from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **Functions and Their Growth Rates** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **Functions and Their Growth Rates** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **Functions and Their Growth Rates** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes