Doubly Linked List Simulator
Visualise prev and next pointer changes when inserting, deleting and traversing a doubly linked list in both directions.
Operations
Doubly linked list
Green = new node, orange = nodes whose pointers change, blue = visited.
Each node: ◀ prev | value | next ▶
Drag to move · scroll to zoom
Pseudocode
The current line is highlighted.
About This Simulation
This doubly linked list simulator shows how the prev and next pointers change when you insert, delete and traverse. Every pointer update is a separate step, so you can see exactly which links change and in what order.
Features
- Insert at the head, the tail or a given position
- Delete a node by value with both links updated
- Forward traversal from the head and backward traversal from the tail
- Each node shows its prev pointer, value and next pointer
- Pseudocode with the active line highlighted
Topics covered
- Doubly Linked List
- Prev and Next Pointers
- Head and Tail
- Insertion and Deletion
- Bidirectional Traversal
Explanation
In a doubly linked list each node stores a value and two pointers: next points to the following node and prev points to the one before. The list keeps a head pointer to the first node and a tail pointer to the last, so it can be walked in either direction.
How it works
- Insert at the head: the new node's next points to the old head, the old head's prev points back to the new node, then head moves to the new node.
- Insert at the tail: the new node's prev points to the old tail, the old tail's next points to the new node, then tail moves.
- Insert in the middle changes four pointers: the new node's prev and next, the previous node's next and the following node's prev.
- Delete a node by pointing its previous node's next past it and its next node's prev back past it, updating head or tail at the ends.
- Traverse forwards by following next from the head, or backwards by following prev from the tail.
Why it matters
Doubly linked lists are used for browser history, undo/redo, music playlists and the LRU caches in operating systems. They are a core topic in data structures courses such as CSE220.
Frequently Asked Questions
What is the difference between a singly and a doubly linked list?
A singly linked list node only points to the next node. A doubly linked list node also points to the previous node, so the list can be traversed in both directions.
Why use a doubly linked list?
Given a node, you can delete it or insert before it in O(1) time, because you can reach the node before it directly through prev.
What is the cost of a doubly linked list?
Every node needs extra memory for the prev pointer, and every insertion and deletion must update more pointers.
Related Simulations
Data Structures
Linked List Simulator
Insert, delete and search in a linked list stored in arrays, with the start and free pointers and every pointer change shown step by step.
Data Structures
Queue (ADT) Simulator
Show enqueue, dequeue, front, rear, overflow, and underflow.
Data Structures
Stack (ADT) Simulator
Visualise push, pop, overflow, and underflow operations
Data Structures
B+ Tree
Insert, delete, search in a B+ tree visualiser

