Dynamic Array
An array that doubles its capacity when full, so appends are amortized O(1).
Decision · step 2 of 9Dynamic Array: Append five values
Append 3 at index 0. Size 1 of 2.
What you will see
FILL -> FULL -> ALLOCATE 2x -> COPY -> CONTINUE; empty capacity slots are visible.
Cost
| access | O(1) |
|---|---|
| append | O(1) amortized |
| insert | O(n) |
| delete | O(n) |
| Space | O(n) |
Append is O(n) on the resize step and O(1) otherwise; amortized O(1).
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, try operations in any order.
Screen readers: Each element is an accessibility element with position, value and state; structural changes are announced per step.
Reduced motion: Elements appear at their destination with a crossfade; no travel longer than the element's own size.