A linked list is a data structure that stores items as a chain of nodes, where each node holds a value plus a pointer to the next node. Instead of sitting in one continuous block of memory like an array, the items can be scattered anywhere, connected only by those pointers. It is a classic teaching structure and genuinely useful in a few cases, but in 2026 a dynamic array is the better default for most everyday code.
How a linked list works
Picture a treasure hunt: each clue tells you where the next clue is. A node is a clue. It carries a value and the address of the next node. To find the fifth item you start at the first node and follow pointers four times. There is no shortcut to the middle, because the nodes are not laid out in order in memory.
-- a tiny singly linked list node
class Node:
def __init__(self, value):
self.value = value
self.next = None -- points to the next node, or None at the end
a = Node(1)
a.next = Node(2)
a.next.next = Node(3) -- chain: 1 -> 2 -> 3
A singly linked list points only forward. A doubly linked list adds a pointer to the previous node, so you can walk both directions at the cost of more memory. Following these chains and reasoning about their cost is the sort of thinking Big O notation was built to describe.
Linked list versus array
| Operation |
Linked list |
Array / dynamic array |
| Access by index |
O(n), walk the chain |
O(1), jump directly |
| Insert or delete at known spot |
O(1), relink pointers |
O(n), shift elements |
| Insert or delete at the end |
O(1) |
O(1) amortized |
| Memory per item |
Higher (stores pointers) |
Lower (just values) |
| Cache friendliness |
Poor (scattered) |
Good (contiguous) |
The headline is simple: linked lists win at splicing nodes in and out once you are already at the spot; arrays win at jumping to any position and at raw speed because contiguous memory is friendly to the CPU cache.
When a linked list actually helps
- Constant-time insertion in the middle, with the position already in hand. If you hold a reference to a node and need to remove it without shifting everything, a linked list shines.
- Building queues and deques. Many language deque implementations use linked structures under the hood for cheap operations at both ends.
- When you genuinely do not need indexing. If you only ever walk front to back, the lack of random access costs nothing.
When to reach for an array instead
- You index by position. Arrays do it instantly; linked lists make you walk.
- You care about speed and memory. Contiguous arrays are cache-friendly and store no per-item pointers, so they are usually faster in practice even when Big O looks similar.
- You want simplicity. A dynamic array (
list in Python, ArrayList in Java, vector in C++) covers the vast majority of needs with less code.
Common misconceptions
- "Linked lists are faster than arrays." Usually the opposite in real programs. The O(1) middle insert is real, but cache misses from scattered memory often make linked lists slower overall.
- "Insertion is always cheap." Only once you are at the insertion point. Finding that point still costs O(n) if you have to walk there.
- "I should use a linked list to avoid resizing." Modern dynamic arrays resize efficiently and amortize the cost, so this is rarely a real concern.
What to skip
- Hand-rolling a list in production. Use the standard deque or dynamic array; they are tested and faster. Build your own only as a learning exercise.
- Choosing a linked list by reflex. Default to an array and switch only when you have a specific need for cheap node splicing.
- Singly linked when you need to go backward. If you walk both ways often, a doubly linked list or a different structure fits better.
FAQ
What is the main advantage of a linked list?
Cheap insertion and deletion once you are positioned at the right node, because you only relink a couple of pointers instead of shifting elements.
Why are linked lists slow to access by index?
There is no formula to compute an item address. You must start at the head and follow pointers one node at a time until you arrive.
What is the difference between singly and doubly linked lists?
A singly linked list points only to the next node. A doubly linked list also points to the previous node, allowing backward traversal at the cost of extra memory per node.
Are linked lists still used in 2026?
Yes, mostly inside other structures like deques and certain queues, and in low-level systems code. For general application work, dynamic arrays are the common default.
Where to go next
See what an array is and how it works, what a data structure is, and what a pointer is in programming.