A linked list is a sequence of nodes where each node stores a value and a pointer to the next node. Unlike arrays, nodes do not sit next to each other in memory — they can be anywhere. The pointer is the only thing that holds the list together. Understanding linked lists means understanding that a pointer is not an arrow on a diagram — it is a real value stored in memory.
Every linked list is made of nodes. A node is a small structure with two parts: a data field that holds the actual value, and a pointer field (called NEXT) that holds the memory address of the next node. When there is no next node, NEXT holds NULL — a special value meaning "nothing follows."
The value 0x1C stored in the NEXT field is not an arrow — it is a real hexadecimal number sitting in memory. To reach the next node, the computer reads this number and jumps to that address. This is pointer traversal.
Each node has one pointer — NEXT — pointing forward. Traversal is one-directional only: you can move from HEAD toward NULL but never backwards. This is the simplest and most memory-efficient form.
Each node has two pointers — PREV pointing to the previous node and NEXT pointing to the next. Traversal works in both directions. Deletion is more efficient because you can reach the predecessor directly from the node being deleted.
The last node's NEXT points back to the first node instead of NULL. There is no end — the list forms a loop. Every node can reach every other node by following pointers long enough. A TAIL pointer is usually maintained to allow O(1) insertion at the end.
Elements are always maintained in ascending order. Every insertion performs a traversal to find the correct position before wiring the new node in — keeping the list sorted at all times without a separate sorting step. Useful when data arrives in random order but must always be retrievable in sorted sequence.
Every operation on a linked list works by following pointers. The key skill is knowing which pointer to change, in which order. Getting the order wrong can permanently lose access to part of the list.
| Operation | Singly | Doubly | Notes |
|---|---|---|---|
| Access by index | O(n) | O(n) | Must traverse from HEAD — no formula |
| Search by value | O(n) | O(n) | Linear scan always |
| Insert at front | O(1) | O(1) | 2 pointer changes only |
| Insert at end | O(n)* | O(n)* | O(1) if TAIL pointer maintained |
| Insert at position i | O(n) | O(n) | Traverse to position i−1 first |
| Delete at front | O(1) | O(1) | Update HEAD only |
| Delete by value | O(n) | O(n) find, O(1) unlink | Doubly skips predecessor scan |
| Reverse | O(n) | O(n) | All n pointers must flip |
Node Forge lets you build linked lists from scratch — drag DATA and NEXT fields to forge a node, stamp nodes onto a canvas, wire them with pointer connections, then run search, insert, delete, and reverse operations. Work through all five stages to earn points.