Skip to main content
Back to the DSA atlas
Systems & storage Data structure Advanced

Skip List

Layer multiple forward-pointer lists on top of each other so ordered search behaves like a randomized tree while staying list-based.

skip-listordered-setsearch

Interactive visualization

Use the controls to connect the idea to concrete operations before diving into the full write-up.

level 3
1
7
15
23
level 2
1
4
7
10
15
18
23
level 1
1
4
7
9
10
12
15
18
21
23

Ordered linked lists with express lanes

Top lanes skip far ahead, so search does not need to walk every element.

Family

Systems & storage

Database indexes, cache policies, query operators, sharding, and external-memory algorithms.

Builds on

2 topics

Read these first if you want the surrounding context.

Unlocks

1 next topic

Use these follow-ups when you want to apply the current idea in a richer setting.

Learning paths

2

This topic appears in curated progressions so you can keep moving without guessing the next step.

Choose this over that

Pick the ordered structure that matches the environment

Skip lists compete with trees by trading strict deterministic balancing for simple randomized structure.

Binary Search Tree (BST)

Choose this when: You are teaching or reasoning from the classic ordered-tree mental model.

Choose something else when: You want a production-ready balanced ordered set without extra balancing rules.

Current topic

Skip List

Choose this when: A pointer-based, randomized ordered set fits the implementation or system ergonomics best.

Choose something else when: You need page-oriented storage behavior or stronger deterministic balancing.

Systems & storage Open topic

B+ Tree

Choose this when: The structure lives on storage pages and range scans must be first-class.

Choose something else when: The data stays in memory and simpler pointer logic matters more.

Problem

A linked list is easy to update, but searching it linearly is slow. Balanced trees solve that, but sometimes you want an ordered structure that stays pointer-based, incremental, and easy to implement without rotations.

A skip list is the classic randomized answer.

Intuition

Think of a skip list as several linked lists stacked on top of each other.

  • the bottom level contains every key in sorted order
  • each higher level contains a random subset of the level below it
  • higher levels act like express lanes

Search starts at the top-left, moves right while possible, then drops down one level when it would overshoot.

So the structure behaves like binary search, but on layered linked lists instead of an array.

Random level promotion

Each inserted key is assigned a tower height by coin flips.

random_level(p = 1/2, maxLevel):
    level <- 1
    while level < maxLevel and random() < p:
        level <- level + 1
    return level

Because tall towers are exponentially rare, the structure stays sparse at high levels and dense at low levels.

search(key):
    node <- head
    for level from top down to 0:
        while node.next[level] exists and node.next[level].key < key:
            node <- node.next[level]

    node <- node.next[0]
    if node exists and node.key == key:
        return FOUND
    return NOT_FOUND

The search path keeps moving right and down, which is why the expected time becomes logarithmic.

Insert

Insertion first records where the new node should appear at every level.

insert(key):
    update[0 .. maxLevel] <- predecessors found during search
    level <- random_level()
    node <- new node(key, level)

    for i in 0 .. level-1:
        node.next[i] <- update[i].next[i]
        update[i].next[i] <- node

No rotations are needed. The randomness is doing the balancing work.

Delete

delete(key):
    update[0 .. maxLevel] <- predecessors found during search
    node <- update[0].next[0]
    if node is absent or node.key != key:
        return

    for i in 0 .. node.level-1:
        update[i].next[i] <- node.next[i]

Deletion is just pointer rewiring at the node’s tower levels.

Worked example

Suppose the bottom level contains:

1 -> 3 -> 6 -> 9 -> 12 -> 15

and higher levels keep only some of those keys, for example:

  • top level: 1 -> 9 -> 15
  • middle level: 1 -> 6 -> 9 -> 15
  • bottom level: every key

Searching for 12 jumps right on upper levels until 15 would overshoot, then drops down and continues. That is the same intuition as jumping by larger and larger blocks in a search tree.

Complexity

OperationExpected timeSpace
SearchO(log n)O(n) expected
InsertO(log n)O(n) expected
DeleteO(log n)O(n) expected

The guarantees are expected, not worst-case deterministic, because balancing comes from randomness.

When to choose a skip list

StructureStrengthWeakness
Skip listSimple pointer updates, randomized balancing, good systems ergonomicsExpected bounds only
Balanced BSTDeterministic worst-case guaranteesRotations and more structural bookkeeping
TreapTree-shaped randomized balancingStill tree rotations, not list-based
B+ TreeGreat page locality and range scans on storageHeavier page-oriented machinery

Skip lists are especially attractive when you want a lightweight ordered set or map that plays well with concurrent or write-buffered systems code.

Key takeaways

  • A skip list is a linked-list answer to ordered search.
  • Randomized tower heights replace explicit balancing rules and rotations.
  • Search is a repeated right-or-down walk through express lanes.
  • The implementation is often simpler than a balanced tree, which is why skip lists show up in real systems.
  • LSM-tree memtables frequently use skip lists because inserts are simple and ordered iteration is natural.

Practice problems

ProblemDifficultyKey idea
Design SkiplistHardImplement randomized levels directly
Skip list overviewHardSearch and insertion with layered pointers
Pugh’s original skip list paperHardWhy random levels give expected logarithmic behavior

Relation to other topics

  • Linked List provides the pointer-based base layer a skip list extends.
  • Binary Search gives the ordered-search intuition even though skip lists are not arrays.
  • Binary Search Tree and Treap are tree-shaped alternatives to the same ordered-set problem.
  • LSM Tree memtables are often implemented as skip lists in practice.

Build on these first

These topics supply the mental model or underlying structure that this page assumes.

What this enables

Once the current idea feels natural, these are the most useful next jumps.

Related directions

These topics live nearby conceptually, even if they are not direct prerequisites.

More from Systems & storage

Stay in the same family when you want parallel variations of the same mental model.

Paths that include this topic

Follow one of these sequences if you want a guided next step instead of open-ended browsing.

Ordered structures

See how order can come from sorted arrays, search trees, skip lists, disk-friendly indexes, heaps, and prefix trees.

Storage engines

Compare fanout-heavy indexes, write-optimized trees, and external-memory sorting in one storage-oriented path.

From the blog

Pair the atlas with recent writing from the rest of the site when you want a broader engineering perspective alongside the topic graph.