Home▸Algorithms & AI▸Data Structures Simulation

Dynamic Array — Amortized Resizing

Interactive 3D dynamic array simulator: push and pop elements, watch capacity double when the array fills up, and see live readouts prove why the amortized cost per push stays O(1) even though a resize itself costs O(n).

Algorithms & AI2DModerate60 FPS📱 Mobile-adapted
computer-science-data-structures-simulation ↗ Open standalone

Every general-purpose dynamic array — Java's ArrayList, C++'s std::vector, Python's list — hides the same trick: it over-allocates, and only pays the price of copying everything into a bigger block once in a while. This simulator renders the underlying memory block as a row of 3D cells in real capacity, lets you push and pop elements one at a time or in a burst, and animates the exact moment a resize happens — every existing element flashing amber as it's copied into the new, wider block. Live readouts track size, capacity, load factor, how many resizes and element-copies have happened in total, and the running average cost per push, which is the number that actually demonstrates the O(1) amortized bound: it climbs during a resize and then decays back down as more O(1) pushes dilute it, converging toward a small constant no matter how large the array grows.

⚙ Under the hood

This simulation explores the concept of data structures – methods for organizing and storing data efficiently. It demonstrates how different data structures can be used to optimize performance in various applications.

Data StructuresArraysLinked Lists

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)