Playground

Doubly Linked List

Visualize bi-directional node traversal and complex pointer reassignments interactively.

Doubly Linked List

A linear data structure containing a sequence of nodes. Each node stores data, a pointer to the next node, and a pointer to the previous node. Visualized here are inserts and deletes at any index, showing traversal and bi-directional pointer logic.

class Node {
data: any;
next: Node | null;
prev: Node | null;
}
Idx
HEAD(Start)
NULL

INSERT

newNode = Node(value)
If list is empty:
HEAD = newNode
If index == 0:
newNode.next = HEAD, HEAD.prev = newNode
HEAD = newNode
Else:
curr = HEAD, Traverse to index - 1
newNode.next = curr.next
If curr.next != NULL: curr.next.prev = newNode
curr.next = newNode
newNode.prev = curr
Return success

Console Output

SIZE: 0
>Waiting for operations...