Learning path

Full curriculum

Full curriculum

Unit content

Amortized analysis

Amortized analysis bounds the average cost of operations over a sequence without assuming that the operations are random.

Some individual operations may be expensive while occurring rarely. A dynamic array, for example, occasionally allocates a larger block and copies many elements, but most appends are cheap.

If capacity grows geometrically, the total copying performed across $n$ appends is still

$$O(n),$$

so the amortized cost per append is

$$O(1).$$

This is different from average-case analysis: no probability distribution over inputs is required.

Common proof techniques include aggregate analysis, assigning extra credits to cheap operations, and defining a potential function that stores accounting value in the data structure's state.