You manipulate a linked list by changing or following references between nodes. In a singly linked list, each node stores data and a reference to the next node, while head refers to the first node.
Core operations
| Operation | Mechanism | Typical time complexity |
|---|---|---|
| Insert at head | Set new.next to head, then set head to new | |
| Insert after a known node | Set new.next to current.next, then set current.next to new | |
| Delete the head | Set to |