1. Data structuresDynamic arrays
Dynamic arrays
A dynamic array is a list that lives in one unbroken stretch of memory but can still grow, like Python’s list, Java’s ArrayList or C++’s vector. Because the items sit side by side, jumping to item 500 is instant: you compute its address directly. When the block fills up, the array grabs a bigger one (usually 1.5 or 2 times the size), copies everything over and frees the old one. Those copies are rare enough that adding an item still costs constant time on average. It’s the default container in most languages, and its tight memory layout is also why it scans faster than almost anything else.
In this lesson: Push items and watch capacity double while a cost-per-push chart shows rare spikes averaging out. Compare growth factors. At L3, contiguous memory lights up whole cache lines next to a linked list scattered across RAM.