algo·visual

Doubly Linked List

Data Structures
avgO(n)worstO(n)spaceO(n)
14
head
36
7
tail

3 nodes linked both ways, from head 14 to tail 7

1 / 42
Starting contents3 values
Operations6 / 40
  1. 1. insert(52)
  2. 2. insert(21 @ 2)
  3. 3. insert(3 @ 0)
  4. 4. delete(36)
  5. 5. search(52)
  6. 6. delete(52)

How it works

Every node links both to its successor and its predecessor, and the list keeps a tail pointer. That makes appends and removals of a known node O(1), at the cost of one extra pointer per node and twice the rewiring on every edit.

Complexity

Best
O(1)
Average
O(n)
Worst
O(n)
Space
O(n)

Search algorithms

Jump to any algorithm or page