Data structures and algorithms · Linked lists
Linked lists
Nodes that point at the next node. · 10 minutes
A linked list is a chain of small objects — nodes — each holding a value and a reference to the next node. The list is known by its first node, the head; the last node's next is None.
The exercises provide Node and a helper build([1, 2, 3]). Step the example and look at the heap: each node is a box, and next is an arrow to another box.
Building and walking a chain of three nodes.
Ctrl + Enter runs
Predict first
a → b → c. You run a.next = c. What happened to b?