[ ] Arrays
02 — Data Structures
A visual guide to contiguous indexed memory

The Array

A row of numbered boxes in one block of memory. Instant to read by index — but inserts and deletes have to shuffle everyone over.

An array stores its items back-to-back in a single contiguous block of memory. Every slot is the same size and carries a number — its index, starting at 0. Because the computer knows where the block begins and how big each slot is, it can jump straight to any index with one calculation. That's the array's superpower — and its catch: to insert or remove anywhere but the end, everything after has to shift over.

Try it in 3D

The big number is the value; the small number underneath is the index. Press an operation and watch the cost play out.

Drag to rotate — scroll to zoom
Press an operation to see it animate. ready
Access Scanning Found / added Shifting Removing

The operations

Reads by index are free; edits away from the end pay for the shuffle.

Cost cheat sheet

Longer bar means more work as the array grows. Two operations are free; three scale with n.