Summary

Used for algorithms where an occasional operation is very slow, but most of the other operations are faster.

An operation has amortized cost if for every integer , the cost of operations is


Example of amortized cost:

The following example here has a amortized cost .

operationcosttotalavg
insert555 7
insert5105 7
insert5155 7
insert + resize13287 7
insert7357 7

Difference between average cost and amortized cost

Even though there are scenarios in which the amortized cost is the same as the average cost, it is not necessary that the amortized cost is the same as the average cost.

If the set of operations are arranged to a point where the more expensive operations happen more at the beginning of the set of operations, the amortized cost becomes a conservative estimate of the average cost, and is not necessarily equal to the average cost.