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).Members only · free account
The rest of this lesson, with 6 more sections, 3 drawings, a dry-run simulator and code in JavaScript, Python, Java and C++, opens with a free account.
Was this helpful?
Not ready yet? The Arrays course is free to read, no account needed.
In the rest of this lesson