Mr. Grummel Get the app
← All notes
LEARNING 5 MIN READ DRAFT — FEBRUARY 2028

The two ways to store a list, and the trade-off neither one escapes

An array stores elements in one contiguous memory block, giving instant access by position but requiring a shift on insertion, while a linked list scatters elements connected by pointers, making insertion fast but position-based access slow.

An array stores its elements in one contiguous, unbroken block of memory, one element immediately after another, which gives it instant access to any element purely by calculating its position, but inserting a new element in the middle requires physically shifting every element after that point to make room. A linked list instead stores its elements scattered anywhere in memory, each one connected to the next through an explicit pointer, which makes inserting a new element fast, no shifting required, but makes reaching a specific position slow, since there's no way to jump directly there without following pointers one link at a time from the start.

An array's contiguous layout is what makes position-based access instant

Because an array's elements sit in one unbroken block of memory at known, evenly spaced positions, accessing the element at any given index means a single, direct calculation, starting memory address plus index times element size, with no need to actually walk through the earlier elements first. That same contiguous layout is exactly what makes insertion costly, though: adding an element in the middle requires physically shifting every subsequent element one position over to preserve that unbroken layout, an operation whose cost grows with how many elements sit after the insertion point.

A linked list's scattered layout inverts that trade-off completely

A linked list's elements can sit anywhere in memory, connected purely through pointers rather than by physical adjacency, which means inserting a new element is genuinely fast, just redirecting a couple of pointers, regardless of how many elements the list already holds. That same scattered layout is exactly what makes position-based access slow, though: reaching the element at a given position means following pointers one link at a time starting from the beginning, since there's no direct calculation that can jump straight to an arbitrary position the way an array's contiguous layout allows.

An array stores elements in one contiguous block of memory, giving instant access to any element by position but requiring everything after an insertion point to shift, while a linked list stores elements scattered in memory connected by pointers, making insertion fast but position-based access slow.

What we're still unsure about

That arrays and linked lists genuinely trade access speed against insertion speed in exactly this opposing way is well established, foundational computer science confirmed through decades of careful algorithmic analysis. What's more genuinely a matter of practical engineering judgement is exactly which structure actually performs better for a given real application once factors beyond the basic trade-off, memory layout effects on modern hardware caching, the actual mix of insertions versus lookups a program performs, are taken into account, and software engineers continue to make different, context-dependent choices between arrays and linked lists, and their many variants, rather than one structure being universally faster in every real situation.

This sits inside Arrays & Linked Lists, one of eight topics in Data Structures, one of seven domains in Computer Science, one of seventeen subjects the app can quiz you on.

Draft — not published yet.
Try the pop quiz