The idea
Key formulas
Capacity growth
Elements copied
Loading lessons…
Just a moment, getting everything ready. The first load can take up to a minute.
Data structures and algorithms
See how a doubling strategy resizes a dynamic array and makes append constant-time amortized.
A dynamic array stores elements in a contiguous buffer. When it fills, it allocates a larger buffer, copies the old elements, then appends. Doubling capacity makes these expensive copies occasional rather than constant.