Foundations - Big-O Notation
How to count the work an algorithm does, why only the growth shape matters, the classes from O(1) to O(n!) with real operation counts, and how to analyse loops, recursion and amortized costs the way interviewers expect.
Big-O answers one question: if I make the input bigger, how much more work does the algorithm have to do? It does not predict seconds. It predicts the shape of the growth curve. Think of a dinner party: handing one plate to the host is the same effort for 10 guests or 10,000 (constant), greeting each guest once grows in step with the crowd (linear), and making every guest shake hands with every other guest explodes (quadratic). When you can count the steps and name the shape, you can say whether a solution survives a million users before you run it.
Builds on
- Logarithms — every O(log n) claim is a count of halvings.
- Arrays in memory — shifting and copying array elements is the hidden cost behind several traps.
What Big-O actually measures
Suppose a friend says their program takes 3 seconds. Is that good? It depends on the laptop, the language, what else is running, and how much data they fed it. Seconds are a bad way to compare ideas, because they mix the idea with the machine. Computer scientists wanted a measurement that survives a change of machine, so they stopped asking how long and started asking how the work grows.
Here is the everyday picture. You are cooking for guests. Reading the single instruction on the box takes the same effort whether you feed 4 people or 400. Stirring one pot takes longer in proportion to how much soup is in it. Making every guest personally introduce themselves to every other guest takes about four times as long when the guest list doubles. Those three behaviours (constant, proportional, squared) are what Big-O names.
Now the precise version. Let n be the size of the input, for example the number of elements in an array. Let f(n) be the number of basic operations the algorithm performs on an input of that size. Big-O is a statement about how fast f(n) grows when n becomes large. Saying an algorithm is O(n) promises that, for large enough n, the work never exceeds some fixed multiple of n.
Why bother with growth instead of timing it? Because small inputs lie. An algorithm that is a little slower at 100 items can be a million times slower at 10 million items. Interviewers care about Big-O because it tells you in thirty seconds whether a solution will survive production data, before anybody runs a benchmark.
| You double the input; the work... | Growth class | Everyday example |
|---|---|---|
| stays the same | O(1) | Read the first item of a list |
| goes up by one step | O(log n) | Look up a name in a sorted phone book by repeatedly halving |
| doubles | O(n) | Read every page of a book |
| quadruples | O(n^2) | Compare every pair of people in a room |
| gets squared | O(2^n) | Try every possible subset of the items |
Check yourself
A program is O(n). You feed it twice as much data. What does Big-O promise about the work?
Counting operations
Before you can name a Big-O class you need a count. Pick a small set of steps and agree that each costs 1: one comparison, one addition, one array read or write, one assignment. This is a model, and the model is deliberately simple. Real processors differ in how fast each step is, but the number of steps and how it grows with n stay the same, and that is what we want.
A worked example. Walk this function by hand for an array of length 4, and count the loop body each time it runs. The setup line runs once, the first loop runs n times, and the nested pair loop runs once for every pair of positions i < j.
function analyse(arr) { let total = 0; // 1 operation, runs once for (const v of arr) total += v; // n operations for (let i = 0; i < arr.length; i++) for (let j = i + 1; j < arr.length; j++) if (arr[i] === arr[j]) total++; // n(n-1)/2 operations return total;}Notice how lopsided the three parts are. At n = 1,000 the pair loop contributes 499,500 of the 500,501 operations, which is over 99.8 percent. The single setup step and the linear loop barely register. That lopsidedness is the whole reason Big-O can throw parts away: the biggest part decides the story.
One statement costs 1
arithmetic, a comparison, an assignment, reading or writing one array slot all count as a single operation in the model.
A loop multiplies its body
a loop that runs n times around a body costing c does n times c operations in total.
Sequential code adds
a loop followed by another loop costs the sum of both. Add the costs, then keep the larger.
Nested code multiplies
a loop inside a loop costs the outer count times the inner count, unless the inner bound depends on the outer variable.
A function call costs its body
calling something that is itself O(n) inside your loop makes the loop O(n) times bigger.
Check yourself
In the function above, how many operations does the nested pair loop perform for n = 10?
Dropping constants and small terms
Two simplifications turn the exact count into a Big-O class. First, drop lower-order terms: they stop mattering as n grows. Second, drop the constant multiplier on the term that remains. So 2n^2 + 30n + 8 becomes n^2, and 5n + 300 becomes n. The result is a shape, with every detail about the machine and the exact implementation erased.
| Exact count | Drop small terms | Drop constant | Big-O |
|---|---|---|---|
| 3n + 20 | 3n | n | O(n) |
| 2n^2 + 30n + 8 | 2n^2 | n^2 | O(n^2) |
| n + n log n | n log n | n log n | O(n log n) |
| 500 | 500 | 1 | O(1) |
| n^3 + 1000 n^2 | n^3 | n^3 | O(n^3) |
Why is dropping the constant legitimate? Because a constant factor is the same for every n and so it never changes the shape. If one machine does each operation twice as fast, every algorithm gets the same factor of two. A change of shape, say from n to n^2, cannot be rescued by any constant: for large enough n the quadratic always loses.
The right habit in an interview is to say both halves: 'This is O(n log n), so it will scale to millions of items, and I would measure the constants before micro-optimising.' That sentence shows you know what Big-O covers and what it leaves out.
Check yourself
Which is the correct simplification of 7n^3 + 400n^2 + 9n + 12?
The classes and real operation counts
Memorise the order and, more importantly, feel the gaps. Here is the full ladder with actual operation counts. The logarithm is BASE 2, rounded; n log n is rounded to the nearest integer where it fits. For the two giants, the exact value has far too many digits to write, so the table gives its size in powers of ten.
| Class | n = 10 | n = 100 | n = 1,000 | n = 1,000,000 |
|---|---|---|---|---|
| O(1) | 1 | 1 | 1 | 1 |
| O(log n) | 3.3 | 6.6 | 10 | 19.9 |
| O(n) | 10 | 100 | 1,000 | 1,000,000 |
| O(n log n) | 33 | 664 | 9,966 | 19,931,569 |
| O(n^2) | 100 | 10,000 | 1,000,000 | 1,000,000,000,000 |
| O(2^n) | 1,024 | about 1.27 x 10^30 | about 1.07 x 10^301 | about 10^301,030 |
| O(n!) | 3,628,800 | about 9.3 x 10^157 | about 4.0 x 10^2567 | about 8 x 10^5,565,708 |
Same n, wildly different work. O(2^n) is left off: 2^1000 cannot be drawn. (operations at n = 1,000)
Convert those counts into time with a stated assumption: say a machine performs one billion simple operations per second. That is an assumption for illustration, not a measurement of any real processor. Then O(n log n) at n = 1,000,000 takes about 19.9 million operations, which is around 0.02 seconds. O(n^2) at the same size takes 10^12 operations, which is 1,000 seconds, about 17 minutes.
At a million items the quadratic bar is about 50,000 times taller than n log n. (operations at n = 1,000,000)
Exponential growth is a different animal. At n = 30 an O(2^n) algorithm already does 1,073,741,824 operations (about one second at our assumed rate). At n = 40 it does about 1.1 trillion (roughly 18 minutes). At n = 50 it is 1.13 x 10^15, which is about 13 days. At n = 60 it is about 36 years. Adding ten items multiplies the work by a thousand. Factorial growth is worse still: 10! is 3.6 million, 12! is 479 million, and 20! is about 2.4 x 10^18.
| Class | Typical source | Name it as |
|---|---|---|
| O(1) | array index, hash lookup (on average), push onto a stack | constant |
| O(log n) | Halving the search space: binary search, walking a balanced tree | logarithmic |
| O(n) | One pass over the data: sum, max, linear search | linear |
| O(n log n) | Good sorting: merge sort; divide in half, do linear work per level | linearithmic |
| O(n^2) | Two nested loops over the same data: compare all pairs | quadratic |
| O(2^n) | Trying every subset; naive recursive Fibonacci | exponential |
| O(n!) | Trying every ordering (permutations), brute-force routes | factorial |
Check yourself
At n = 1,000,000, roughly how many times more operations does an O(n^2) algorithm perform than an O(n log n) one?
Best, average, worst case and the three bounds
Two separate questions hide inside a complexity claim, and mixing them up is the most common theory mistake. The first question is which input of size n we are talking about. The second is which kind of bound we are placing on the resulting growth.
Which input. Searching an unsorted array for a target by scanning left to right shows the three cases. Best case: the target is first, so one comparison. worst case: the target is last or missing, so n comparisons. Average case: if the target is equally likely to be anywhere, you look at about (n + 1) / 2 items, which is still linear. Engineers usually plan for the worst case because it is a guarantee, while the average case describes typical load.
| Algorithm | Best case | Average case | Worst case |
|---|---|---|---|
| Linear search | O(1): found first | O(n): about n / 2 checks | O(n): last or absent |
| binary search (sorted) | O(1): hit the middle | O(log n) | O(log n): about 20 for a million items |
| Insertion sort | O(n): already sorted | O(n^2) | O(n^2): reverse sorted |
| Hash table lookup | O(1) | O(1) with a good hash | O(n): everything collides into one bucket |
Which bound. Big-O, Big-Omega and Big-Theta are three precise statements. Let f(n) be the cost and g(n) a simple comparison function such as n^2. We say f is O(g) if there are constants c > 0 and n0 such that f(n) <= c g(n) for every n >= n0: g is an upper bound. We say f is Omega(g) if f(n) >= c g(n) from some point on: g is a lower bound. We say f is Theta(g) if it is both, meaning g is a tight bound.
In everyday interviews people say O(n) when they mean Theta(n), the tight bound. Strictly, an O(n) algorithm is also O(n^2), because n^2 is also an upper bound, just a loose one. When you want to be careful, say 'tight' or use Theta. If an interviewer asks for the lower bound of comparison-based sorting, they are asking for Omega: any algorithm that sorts by comparing elements needs at least on the order of n log n comparisons in the worst case.
Check yourself
Which statement about f(n) = 3n + 5 is true?
Analysing loops
Loops are where most interview analysis happens. The recipe is always the same: work out how many times the body runs in total, then multiply by the cost of one run of the body. The cases below cover almost every loop you will meet.
| Loop shape | Body runs | Class |
|---|---|---|
| for i < n | n | O(n) |
| for i < n, then a separate for j < n | n + n = 2n | O(n) |
| for i < n { for j < n } | n x n | O(n^2) |
| for i < n { for j = i + 1 ... n } | n(n-1)/2 | O(n^2) |
| for i = 1; i < n; i *= 2 | about log2 n | O(log n) |
| for i < n { for j = 1; j < n; j *= 2 } | n x log2 n | O(n log n) |
| for i < 1000 (a fixed number) | 1,000 | O(1) |
The dependent bound. When the inner loop starts at i + 1, it runs n-1 times for i = 0, n-2 times for i = 1, and so on down to 0. Add those up: (n-1) + (n-2) + ... + 1 + 0. The classic pairing trick says that the first and last terms add to n-1, the second and second-last add to n-1 again, and there are n/2 such pairs.
10 pairs = 5 x 4 / 2, about half of the 25 cells of a full n x n grid
The doubling counter. In for (i = 1; i < n; i *= 2) the counter takes the values 1, 2, 4, 8, ... until it passes n. The number of iterations is the number of times you can double before reaching n, which is log2 n. For n = 1,024 the counter hits 1, 2, 4, ..., 512, which is 10 iterations. Halving works the same way in reverse. Plain English test: if the counter moves by a multiplier or a divisor instead of by a fixed step, the loop is logarithmic.
let a = 0;for (let i = 0; i < 1000; i++) for (let j = i + 1; j < 1000; j++) a++; // 499500let b = 0;for (let i = 1; i < 1024; i *= 2) b++; // 10let c = 0;for (let i = 0; i < 1024; i++) for (let j = 1; j < 1024; j *= 2) c++; // 10240 = 1024 x 10console.log(a, b, c);A final loop warning: the bound to count is the bound at runtime. A loop written as while (x > 0) x = x - 1 is linear in the starting value of x, but a loop written as while (x > 0) x = Math.floor(x / 2) is logarithmic in it. The visible shape of the update line is what decides the class.
Check yourself
How many times does the inner statement run in: for i in 0..n-1, for j in i+1..n-1, with n = 100?
Analysing recursion
A recursive function calls itself on a smaller problem, so its cost refers to itself. We write that as a recurrence: T(n) is the cost on size n, expressed using T of smaller sizes plus the non-recursive work. Then we unroll it step by step until it reaches the base case. Three recurrences cover most interview problems.
| Pattern | Recurrence | Result | Example |
|---|---|---|---|
| One call on half the input, constant extra work | T(n) = T(n/2) + 1 | O(log n) | binary search |
| Two calls on halves, linear extra work | T(n) = 2T(n/2) + n | O(n log n) | merge sort |
| One call on n-1, constant extra work | T(n) = T(n-1) + 1 | O(n) | Sum a list recursively |
| Two calls on n-1 or n-2, constant extra work | T(n) = T(n-1) + T(n-2) + 1 | O(2^n) | Naive Fibonacci |
Unrolling halving. For T(n) = T(n/2) + 1, replace T(n/2) with T(n/4) + 1, and so on. After k expansions we have T(n/2^k) + k. The recursion stops when n/2^k reaches 1, which is k = log2 n. So T(n) = log2 n + T(1), which is O(log n). Concretely, searching 1,024 items takes 10 halvings, and searching 1,000,000 takes 19 or 20.
Unrolling merge sort. For T(n) = 2T(n/2) + n, think of the recursion as levels. Level 0 has 1 problem of size n, level 1 has 2 problems of size n/2, level 2 has 4 problems of size n/4. At every level the sizes add up to n, so each level does n work. There are log2 n levels, so the total is n log2 n.
Why two calls on n-1 is exponential. Naive Fibonacci calls itself twice per call. The number of calls roughly doubles each time n goes up by one, and the tree of calls is n levels deep. Counting the calls with the runnable code gives fib(10): 177 calls, fib(20): 21,891 calls, fib(30): 2,692,537 calls. Each +10 multiplies the count by over 100, matching exponential growth (the true growth factor is about 1.618 per step, golden-ratio shaped, so O(2^n) is a valid upper bound while 1.618^n is the tight one).
function fibCalls(n) { let calls = 0; (function fib(k) { calls++; return k < 2 ? k : fib(k - 1) + fib(k - 2); })(n); return calls;}console.log(fibCalls(10), fibCalls(20), fibCalls(30)); // 177 21891 2692537One more factor beginners forget: recursion uses memory too. Each active call sits on the call stack. A recursive sum of n items needs n frames of stack at once, so it uses O(n) space even though it creates no array. binary search written recursively uses O(log n) stack space; written as a loop it uses O(1).
Check yourself
A function calls itself twice on inputs of half the size and does n units of other work. What is its cost?
Amortized cost and space complexity
Some operations are usually cheap and occasionally expensive. Judging them by the worst single call is too pessimistic, and judging them by the best is too hopeful. amortized analysis averages the cost over a long sequence of operations. It is a guarantee about the total, with no randomness involved, which makes it different from an average case.
The standard example is appending to a dynamic array. The array lives in a block of memory with a fixed capacity. While there is room, an append writes one slot: cost 1. When the block is full, the array allocates a block twice as large, copies every element across, and then appends. That one append costs len + 1, which is O(n). Yet most appends are cheap. Let us add it up.
The doubling series 1 + 2 + 4 + ... + 2^k adds up to 2^(k+1) - 1, which is always less than twice the last term. So however many appends you do, the total copying stays under 2n and the whole sequence costs under 3n operations. Spread across n appends, each costs under 3 on average: amortized O(1). The same trick works with any growth factor greater than 1, though the constant changes.
space complexity counts memory the same way time complexity counts operations: how much extra memory does the algorithm need as n grows? We usually count extra memory beyond the input itself, called auxiliary space. A function that sums an array with one running total uses O(1) extra space. A function that builds a copy of the array uses O(n). A recursion n levels deep uses O(n) stack.
| Algorithm | Time | Extra space | Note |
|---|---|---|---|
| Sum an array with a loop | O(n) | O(1) | One running total |
| Copy an array | O(n) | O(n) | A second array of equal size |
| binary search (loop) | O(log n) | O(1) | Two index variables |
| merge sort | O(n log n) | O(n) | A temporary array to merge into |
| Naive recursive Fibonacci | O(2^n) | O(n) | stack depth is n, even though time is exponential |
Time and space often trade against each other. A hash set of already-seen values makes duplicate detection O(n) time instead of O(n^2), at the price of O(n) extra space. Interviewers like it when you name this trade-off aloud.
Check yourself
A dynamic array doubles its capacity when full. Appending n items from empty copies roughly how many elements in total?
Traps interviewers love
Most wrong answers in interviews do not come from the maths. They come from a line that looks cheap and is not, or from counting the wrong variable. Here are the traps that appear again and again.
Hidden O(n) inside a loop. Building a string with s = s + ch in a loop can look like O(n) overall. In a language where strings are immutable, each concatenation may create a new string and copy everything built so far. Adding characters one at a time then copies 0 + 1 + 2 + ... + (n-1) characters, which is n(n-1)/2, so n = 1,000 means 499,500 character copies. Some runtimes optimise this, so treat the quadratic answer as the safe assumption in an interview and mention the alternative: collect pieces in an array and join once, which is O(n).
Removing the first element of an array shifts every remaining element one slot left. A loop that repeatedly removes the front of an array therefore performs n-1, n-2, ... shifts, about n(n-1)/2 in total: 499,500 for n = 1,000. Some engines make this cheaper in special cases, so quote it as O(n) per removal in the standard array model. A queue structure, or an index that moves forward instead, avoids the cost.
// Quadratic in the usual model: each shift moves every remaining elementfunction drainSlow(items) { let moved = 0; while (items.length > 0) { moved += items.length - 1; items.shift(); } return moved;}// Linear: just advance an indexfunction drainFast(items) { let touched = 0; for (let i = 0; i < items.length; i++) touched++; return touched;}const data = Array.from({ length: 1000 }, (_, i) => i);console.log(drainSlow([...data]), drainFast(data)); // 499500 1000Using the wrong n. Big-O needs you to say what n is. If a function takes two arrays of lengths a and b, a nested loop over both is O(a x b), and calling it O(n^2) silently assumes a equals b. A function that loops over a matrix with r rows and c columns does r x c work, which is O(n) in the number of cells but O(n^2) if you call n the side length of a square matrix. State your variables out loud.
Numeric inputs: size is the number of digits. If the input is a single number x, such as in a primality test, the honest measure of input size is how many bits or digits it takes to write x, which is about log2 x. Trial division checks divisors up to the square root of x. For x = 1,000,000,007 that is only 31,621 checks, but as a function of the bit length b (here b = 30) the work is about 2^(b/2), which is exponential in the input size. A loop that counts up to x is O(x) in value, yet exponential in the number of bits.
| Trap | What looks true | What is true | Fix |
|---|---|---|---|
| String concatenation in a loop | O(n) | Possibly O(n^2) copying | Collect in an array, join once |
| Remove from the front of an array | O(1) | O(n) per removal | Use a queue or move an index |
| arr.includes inside a loop | One line, O(n) total | O(n^2) overall | Put items in a hash set first |
| Two inputs, one letter | O(n^2) | O(a x b) | Name each size separately |
| Counting up to a number x | Linear | Exponential in the bit length of x | Say 'pseudo-polynomial' |
Check yourself
A loop removes the first element of a 1,000-element array 1,000 times using shift, which moves every remaining element. About how many element moves occur?
Interview script: say it in 60 seconds
Interviewers are not just checking the final class. They want to hear the reasoning and see that you notice the cases. Use the same script on every problem so that nerves cannot make you skip steps.
010:00 Name n
State what the variables are: 'Let n be the length of the array; the target is a single value.'
020:10 Count the work
Walk the code and say what runs how many times: 'The outer loop runs n times, the inner loop runs up to n-1 times.'
030:25 Give the exact count
If it is clean, write it: 'That is n(n-1)/2 comparisons, about 500,000 for n = 1,000.'
040:35 Simplify
Keep the dominant term and drop the constant: 'So the time is O(n^2).'
050:45 Add the case and the space
Mention worst versus best: 'The worst case is the one I quoted. Extra space is O(1), only two indices.'
060:55 Offer the improvement
Close with the trade: 'With a hash set I can get O(n) time for O(n) extra space; I can code that if you like.'
Finally, avoid two common over-claims. Do not call a solution optimal unless you can argue a lower bound for the problem. And do not say a hash table is always O(1): it is O(1) on average with a good hash function, and the worst case degrades to O(n) when many keys collide.
Recap
Big-O describes how work grows with input size. It is a shape, not a stopwatch reading.
Count basic operations, then keep only the dominant term and drop its constant: 2n^2 + 30n + 8 is O(n^2).
Ordered by growth: O(1), O(log n), O(n), O(n log n), O(n^2), O(2^n), O(n!). At n = 1,000,000 the quadratic cost is 10^12 operations against about 2 x 10^7 for n log n.
Nested loops multiply; sequential loops add; a dependent inner bound j > i gives n(n-1)/2, still O(n^2). A loop that doubles or halves its counter is O(log n).
recursion: one call on half the input is O(log n); two calls on half plus linear work is O(n log n); two calls on n-1 is exponential.
Best, average and worst case describe which input; O, Omega and Theta describe which kind of bound. They are separate ideas.
amortized O(1) for dynamic-array append: doubling means total copies stay under 2n, so each append costs under 3 operations on average.
Watch for hidden linear work (string concatenation in a loop, shifting an array) and be exact about what n means, especially for numeric inputs.
Terms in this lesson
Every acronym and concept, expanded. Tap a term to open it.
space complexity
How much extra memory an algorithm needs as input grows.
time complexity
How an algorithm's number of operations grows with input size.
hash function
A function that maps any input to a fixed-size number, used to place keys in buckets.
balanced tree
A tree kept roughly equal in height on both sides so operations stay O(log n).
binary search
Halving a sorted search space each step to find a value in O(log n).
memoization
Storing a function's result for each input so it is never recomputed - top-down caching.
call stack
The stack of active function calls the runtime tracks; each recursive call adds a frame.
merge sort
A divide-and-conquer sort that splits, sorts halves recursively, and merges them in O(n log n).
subproblem
A smaller instance of the same problem solved on the way to the full answer.
amortized
Averaged over a whole sequence of operations, so one rare expensive step is spread across many cheap ones.
recursion
A function that calls itself with a smaller version of the same problem until it hits a base case.
base case
The stopping condition in recursion - the smallest input the function can answer directly.
algorithm
A precise, step-by-step procedure that solves a problem.
hash set
A hash map that stores only keys, used to answer 'have I seen this?' in O(1).
Big-O
Notation that describes how an algorithm's work grows as its input grows, ignoring constants and hardware.
array
A contiguous block of memory holding items in order, readable by index in O(1).
stack
A last-in-first-out structure: you push on top and pop from the top.
queue
A first-in-first-out structure: items leave in the order they arrived.
BASEBasically Available, Soft state, Eventually consistent
The looser set of guarantees NoSQL stores trade for scale: the system stays available, state is approximate, and replicas catch up over time.
tree
A hierarchy of nodes where each node has one parent and zero or more children.
growth rate
How the amount of work changes as the input gets bigger. Big-O describes this and nothing else.
operation
One basic step we agree to count as cost 1: a comparison, an addition, an array read or write. Counting these is the first step of any analysis.
dominant term
The part of a cost formula that grows fastest. In 2n^2 + 30n + 8 it is n^2, and the rest is dropped.
asymptotic
Describing behaviour as the input grows without bound. Big-O is an asymptotic tool, so it ignores what happens at tiny n.
worst case
The input of a given size that makes the algorithm do the most work. It is the guarantee Big-O usually quotes.
recurrence
An equation that defines the cost of size n using the cost of smaller sizes, such as T(n) = T(n/2) + 1 for binary search.
Big-Omega
A lower bound on growth: f is Omega(g) if f eventually stays above a constant multiple of g.
Big-Theta
A tight bound: f is Theta(g) if f is both O(g) and Omega(g), so it grows exactly at that rate.
constant
A fixed multiplier or fixed extra cost that does not depend on n. Big-O drops it, though real programs still feel it.
Where you will see it
Real systems that use this exact idea. Tap a card to open it.
Common traps
The mistakes interviewers watch for. Guess the fix, then reveal it.
FixBig-O describes growth shape. A slow fixed operation is still O(1), and a quick run on 100 items says nothing about 100 million.
FixDrop constants and lower-order terms: those are O(n), O(n^2) and O(n). Keep the constant only when you are counting exact operations, not stating a class.
FixThat loop runs n(n-1)/2 times, still O(n^2). And cases (best, average, worst) are independent of bounds (O, Omega, Theta): each case can have all three.
Interview prep
Questions you could be asked, with the depth an interviewer wants to hear.
It describes how the work an algorithm does grows with the input size n, keeping only the dominant term and dropping constants, so it compares ideas independent of hardware.
growth rate, not seconds
DeeperDoes O(1) mean fast?