r/tech.unpacked01 · u/tech.unpacked01 ·

How a linked list works

How a linked list works

A linked list never moves its items.

Each node holds a value and the address of the next node, so the nodes can sit anywhere in memory. To put 25 after the first node, an array shifts the five items after it. The list changes two pointers.

The catch: to reach the fifth node you start at the head and follow four pointers. Quick to insert, slow to find.

#linkedlist #datastructures #computerscience #coding #programming