On this page
Underneath a Python list or a Java ArrayList sits a fixed block of memory. When it fills, the program asks for a bigger block and copies everything across, so that append costs O(n). Yet textbooks say append is O(1). Both are true; the second is about amortised cost. If Big O itself feels shaky, start with our guide to Big O notation and growth rates.
What is amortised analysis?
Amortised analysis bounds the total cost of a sequence of operations and then divides by the number of operations (Jeff Erickson, Algorithms lecture notes, Amortized Analysis). There is no probability in it. Robert Tarjan's 1985 survey Amortized Computational Complexity describes amortisation as "averaging over time".
What does one append actually cost?
Count 1 for each element written and 1 for each element copied. Start with capacity 1 and double whenever the array is full. Trace 17 appends:
Appends 2, 3, 5, 9 and 17 find the array full, so they copy 1, 2, 4, 8 and 16 elements before writing.
Every other append costs just 1.
Total copies: 1 + 2 + 4 + 8 + 16 = 31. Total writes: 17. Total work: 48.
Append number 17 costs 17 on its own, yet the whole run costs 48, less than 3 × 17 = 51.
Why do the copies total less than 2n?
The aggregate method in Erickson's notes adds up the cost of all n operations, then divides by n. With doubling, the resizes copy 1, 2, 4 and so on up to the largest power of two below n, call it 2^k. That geometric series sums to 2^(k+1) − 1, and since 2^k < n, the total is less than 2n. Add the n writes and the whole sequence costs less than 3n, so each append costs less than 3 on average: O(1).
How does the banker's method pay for a resize?
The accounting (or banker's) method charges each operation a fixed fee and banks the surplus as credit for later. Charge every append 3 coins: 1 pays for its own write, and 2 stay stored on the element it just added.
Suppose a resize has just copied k elements into a block of capacity 2k, spending all the credit. Before it fills, k new elements arrive and bank 2 coins each: 2k coins, exactly what the next resize needs to copy 2k elements. The bank never goes negative.
How does the potential method prove O(1)?
The potential method stores prepaid work in the whole structure, not on single elements. The amortised cost of operation i is its actual cost plus the change in potential, a_i = c_i + Φ_i − Φ_(i−1) (Erickson's notes).
For a doubling array, use Φ = 2 × (number of elements) − capacity.
An ordinary append costs 1 and raises Φ by 2, so its amortised cost is 3.
A resizing append into a full array of k elements costs k + 1 (copy k, write 1). Before it Φ = 2k − k = k; after it Φ = 2(k + 1) − 2k = 2. The change is 2 − k, so the amortised cost is (k + 1) + (2 − k) = 3.
The array stays more than half full, so Φ never falls below its start and the total actual cost is at most 3n.
Why is growing by a fixed amount quadratic?
Run the same aggregate sum (Erickson's notes) on an array that grows by 10 slots each time. It copies 10, 20, 30 elements and so on. For n = 1,000,000 that is 10 × (1 + 2 + … + 99,999) = 49,999,500,000 copies. Doubling from capacity 1 copies 1 + 2 + … + 524,288 = 1,048,575 elements, about 47,700 times fewer. In general a fixed step c gives roughly n²/(2c) copies: Θ(n²) in total and O(n) amortised per append.
Any growth factor above 1 keeps the series geometric, and CPython and Java pick milder ones than 2. CPython's list grows by about one-eighth plus a small constant, which its source comment says is "enough to give linear-time amortized behavior" (CPython listobject.c). Java's ArrayList prefers to grow by half its old capacity (OpenJDK ArrayList.java).
A five-minute self-test
Starting at capacity 1, list the cost of each of the first 9 appends. (Answer: 1, 2, 3, 1, 5, 1, 1, 1, 9, totalling 24, under 27.)
Redo the banker's argument with 2 coins per append and find the first resize that leaves you in debt.
Work out Φ before and after append 9, and check that the amortised cost comes to 3.
The same growing array often sits under a binary heap priority queue. To see where amortised analysis sits among neighbouring computing ideas, look it up in the Fermi Concept Library. To practise cost traces like these, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.



