← Lessons

quiz vs the machine

Silver1110

Algorithms

The Doubly Linked List

Adding a backward pointer so you can walk and splice in both directions.

4 min read · intro · beat Silver to climb

Pointers in both directions

A doubly linked list extends the singly linked list by giving every node two references: one to the next node and one to the previous node. The list usually keeps both a head and a tail pointer. This small addition unlocks backward traversal and much easier deletion.

Removing a node without searching

In a singly linked list, deleting a node requires knowing the one before it, so you often search for the predecessor. With previous pointers, a node already knows its neighbor on both sides. To remove it you simply:

  • Link its previous node directly to its next node.
  • Link its next node back to its previous node.

That splice happens in constant time given a reference to the node itself.

The cost of the extra link

Nothing is free. Each node now stores an additional pointer, raising memory use, and every insertion or deletion must update more references, so the bookkeeping is more error prone. Many implementations use a sentinel dummy node to avoid special cases at the ends.

Key idea

A doubly linked list adds a previous pointer to each node, enabling backward traversal and constant time deletion of a known node at the price of more memory and bookkeeping.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a doubly linked list add compared to a singly linked list?

2. Why is removing a known node easier in a doubly linked list?

3. What is one cost of the extra backward pointer?