Algorithms

Amortized cost

The average cost of an operation when spread over many: once in a while it costs a lot, but spread out it's little.

Example

Adding at the end of a dynamic list sometimes copies everything, but 1,000 additions cost about 2,300 steps: about 2 each.

Test yourself: Amortized cost

Dynamic lists

What does it mean for adding at the end to be amortized O(1)?

Lessons that use it

More algorithms terms

All terms →

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.