A linked list is a chain of small boxes called nodes. Each node holds two things: a value, and an arrow (a pointer) to the next node. You hold on to the first node — the head — and follow the arrows to reach everything else. The last node's arrow points to null, which means "the list ends here".
In a treasure hunt, each clue tells you where the next clue is hidden. You can't jump to clue number 4 — you have to start at clue 1 and follow the trail. A linked list works exactly the same way:
next pointer).Free account
Sign up to read the rest of this lesson: 6 more sections, 3 drawings, a dry-run simulator and code in JavaScript, Python, Java and C++.
Still to come
Was this helpful?