We're sorry this tutorial wasn't helpful. Please tell us what we can do better.
Advantages and Disadvantages of Singly Linked List
Last updated:
A singly linked list is the simplest linked structure, and its strengths and weaknesses both come from the same design choice: each node knows only the node after it. This page first recalls that structure and then weighs its advantages against its disadvantages.
What is Singly Linked List?
A singly linked list is a chain of nodes. Each node has a data field and a next reference to the following node. The list is reached through a head reference to the first node (null for an empty list), and the last node's next is null.
Because the links point only forward, the list can be walked from the head towards the end but never backwards.
Advantages of Singly Linked List
No fixed capacity: nodes are created one at a time as values are added, so there is no initial size to choose and no array to resize and copy.
O(1) insertion and deletion at the head: only the head reference and one next link change; no other element moves.
O(1) insertion after a known node: once you hold a reference to a node, a new node can be linked in right after it without touching the rest of the list.
Smallest linked node: one reference per node, half the link overhead of a doubly linked list.
Natural building block: stacks, queues (with a tail reference), hash-table buckets and graph adjacency lists are easy to build on it.
Disadvantages of Singly Linked List
The single forward link also limits what the list can do efficiently:
No random access: reaching the k-th node means following k links from the head, O(k); binary search is therefore not practical.
No backward movement: deleting the last node, or the node before a given one, needs an O(n) walk to find the predecessor; printing in reverse needs recursion or a stack.
Extra memory per element: each value carries a reference and, in Java, an object header, so a list of small values uses several times the memory of an array.
Poor cache locality: nodes are scattered in memory, so traversal is slower in practice than looping over an array.
Easy to lose nodes: overwriting a next link in the wrong order cuts off the rest of the list. In Java the cut-off nodes are reclaimed by the garbage collector once nothing refers to them; in C or C++ they would also have to be freed by hand.
Frequently Asked Questions (FAQ)
Q1. What are the main advantages of a singly linked list?
Its size grows and shrinks at runtime.
Insert and delete at the head take O(1) time.
No elements are shifted on insert or delete.
Each node uses less memory than a doubly linked list node.
Q2. What are the main disadvantages of a singly linked list?
No random access: reaching the k-th node takes O(n).
Each node needs extra memory for the next reference.
It can be traversed only forward.
Nodes are scattered in memory, so it is less cache-friendly than an array.
Q3. Why is insertion faster in a linked list than in an array?
Inserting into an array means shifting every later element one place, which is O(n). In a linked list you only change two references, which is O(1) once you have the node. Finding that node still takes O(n), so the real gain is when you insert at the head or at a node you already hold.
Q4. How much extra memory does a linked list node use in Java?
On a typical 64-bit JVM with compressed references, a Node holding an int and a next reference takes about 24 bytes (12-byte object header + 4-byte int + 4-byte reference, padded to 8). The same value in an int[] takes 4 bytes.
Q5. Can a linked list cause a memory leak in Java?
Java's garbage collector frees a node once nothing references it, so simply unlinking a node is enough. A leak happens when a removed node is still reachable, for example from a cache, an iterator or another long-lived structure. Clear those references when you remove nodes.
Q6. Why are linked lists often slower than arrays in practice?
Array elements sit next to each other, so the CPU cache loads many of them at once. Linked list nodes are spread across the heap, and following each next reference can cause a cache miss. Even with the same O(n) complexity, a loop over an array is usually much faster.
Q7. When should you choose a singly linked list over an array?
Choose it when you mostly insert or remove at the front, when the size is unknown and changes often, or when you build a stack or queue. For general-purpose lists in Java, ArrayList or ArrayDeque is usually the better choice.
Q8. How does a singly linked list compare with a doubly linked list?
A singly linked list uses less memory per node and is simpler to code. A doubly linked list can move backward and can delete a node in O(1) when you hold a reference to it, because it already knows the previous node.