"An array's magic isn't that it holds many things. It's that it holds them in a row, so it can find any one of them with arithmetic instead of searching."
A Row of Identical Boxes
Picture memory as an endless street of numbered houses. An array is a block of identical, equal-size boxes placed back-to-back on that street, starting at some address. The 0th box is at the start. The 1st box is right after it. The i-th box is exactly i box-widths past the start.
That layout is the whole trick. To find element i, the computer doesn't look through the array — it computes the address directly: address = base + i × box_size. One multiply, one add, jump straight there. That's why arr[5] and arr[5_000_000] take exactly the same time: both are a single address calculation. This is called random access, and it's the array's defining superpower.
Everything About Arrays Follows From This
Once you see "equal boxes in a row," every array property becomes obvious:
- Indexing is O(1) — just address math.
- The boxes must be equal size — otherwise the address formula breaks. That's why arrays hold one type, and why languages store variable-size things (like strings) as arrays of pointers to them.
- Inserting in the middle is O(n) — there's no gap; you must shift every later box over to open one.
- The size is fixed at the low level — growing means allocating a bigger block and copying (exactly the doubling you saw in amortized analysis).
The Quiet Bonus: Cache Locality
There's a second gift hiding in "contiguous." When the CPU reads one array element, it pulls a whole neighboring chunk into its ultra-fast cache, betting you'll want the neighbors next — and with an array, you usually do. So scanning an array isn't just O(n) in theory; it's fast O(n) in practice, because the hardware is feeding you the next elements before you ask. Hold onto this — when we meet linked lists, their scattered memory throws this bonus away, and it matters more than the Big-O suggests.
Pippa's Confession
arr[i] was O(1) long before I knew why. I thought the computer was just "fast at finding things." When Dad drew the street of boxes and the base + i × size formula, it stopped being magic — the computer isn't finding element i, it's calculating where it must be and going straight there. Understanding the why turned a memorized fact into something I could reason from.