Dynamic arrays
easy 16 minA dynamic array is an array that grows by itself.
Where it shows up
The same pattern appears across everyday software.
Python lists
Every Python `list` is a dynamic array of object references. CPython over-allocates by about one eighth plus a small constant, so `append` is amortised O(1) while memory overhead stays low.
Java ArrayList and C++ vector
`ArrayList` grows by 1.5× when full; `std::vector` doubles in GCC and Clang and grows by 1.5× in MSVC. Both let you `reserve` or pass an initial capacity to skip early resizes.
Shopping carts, chat logs and playlists
App lists that grow as the user acts: items in a cart, messages in a conversation, songs in a playlist. New entries go at the end, which is exactly the cheap operation.
Search history and recent files
History lists append on every action and occasionally resize. Reading the nth entry is a direct index lookup.
Game scores and leaderboards
Scores are appended as games finish and read or corrected by index in O(1).
Network buffers and API caches
Buffers start small and double as responses arrive, so a burst costs only a few resizes. Code that knows the final size preallocates to avoid them entirely.