Home
DSA Visualizer
Data Structures
Doubly Linked List
Doubly Linked List in Data Structure, Visualized
Doubly linked list in data structure: a doubly linked list is a linked list in which each node has two pointers: one to the next node and one to the previous node. Step through it in the interactive Doubly Linked List visualization below.
0 / 8 NODES
READY
List is empty
Insert a value to begin. Each node holds a value and a reference to the next one.
At
Value
Intuition
Like a train where each car is connected to the one in front AND the one behind. You can walk from the engine to the caboose and back.
Concept
A Doubly Linked List allows traversal in both directions. Each node contains data, a next pointer, and a prev pointer.
How Doubly Linked List Works
- Prev Pointer: Points to the previous node.
- Bidirectional: Can traverse forward and backward.
- Memory: Requires more memory than Singly Linked List for the extra pointer.
Doubly Linked List Visualization, Step by Step
- Create new node.
- Set new node's
nextto current Head. - Set current Head's
prevto new node. - Update Head to new node.
When to Use
- Backward Traversal: When you need to navigate back and forth (e.g., Browser History, Music Player).
- Deletion: Deleting a given node is O(1) if you have the pointer to it.
When NOT to Use
- Memory Constraints: Extra pointer takes more space.
- Complexity: More pointers to update during insertion/deletion.
How to Identify
Problems requiring backward traversal or O(1) deletion of a known node.
Practice it on interview problems
LeetCode problems solved with the Linked List pattern, each with a step-by-step visualizer:
Applying for software engineering roles? Free, no sign-up:
AI resume checker: match your resume to the job description
Compare its cost with every other algorithm in the Big O cheat sheet.
