Data Structures · Visualization

Skip List: Search

Skip List

Searching a skip list walks right along the top level as far as possible without overshooting the target, then drops down a level and repeats, using the higher levels as express lanes to skip large chunks of the list. Time: O(log n) expected, O(n) worst case. Space: O(1) auxiliary.

Big-O: Search / insert / delete O(log n) expected thanks to the extra skip lanes.

Skip List: Search

Skip List

Searching a skip list walks right along the top level as far as possible without overshooting the target, then drops down a level and repeats, using the higher levels as express lanes to skip large chunks of the list.

How Search Works

  1. Start at the highest level's leftmost (head) node.
  2. While the next node at this level exists and its value ≤ target, move right.
  3. If the next node would overshoot (value > target) or there's no next node, drop down one level.
  4. Repeat until level 0; check if the current next node equals the target.

Search Worked Example

Input: Search for 9 in the skip list from the Introduction example

  1. Level 2: 3 → 9 (9 ≤ 9, move right); next would be 21 > 9, drop down
  2. Level 1: already at 9, next is 12 > 9, drop down
  3. Level 0: at 9, matches target

Output: Found 9 in 2 moves across levels

Try your own input
SearchO(log n) exp.
Starts at the top lane, jumps right while the next value is not past the target, then drops a level and repeats.
H
L3
H325
L2
H31225
L1
H37121925
L0
H36791217192125∅
Active comparison Skip lane Base level
Search
Press ▶ Run to watch it step by step.
Python · Skip Lists in Code
def search(head, max_h, key):
    cur = head
    for level in range(max_h - 1, -1, -1):
        while (cur.next[level] and
               cur.next[level].key < key):
            cur = cur.next[level]    # jump ahead on fast lane
    cur = cur.next[0]                # land on base level
    return cur.key == key if cur else False
# example: search 9 on [3, 6, 7, 9, 12, 17, 19, 21, 25]
Input: Search for 9 in the skip list from the Introduction example

Behind the Scenes Execution

Press ▶ Run in the visualizer — the call stack, registers and memory will replay here in sync with the code, line by line.

Search Time & Space Complexity

TimeO(log n) expected, O(n) worst case
SpaceO(1) auxiliary

When to Use Search

  • Range queries in sorted in-memory stores
  • Fast membership tests in ordered sets
  • Database index scans

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books Cloud hosting for side projectsShip the portfolio project that gets you hired — free credits for new accounts.Claim credits

Ready for the next step?

See the same ideas in action — visualize the algorithms that operate on these structures, or take a guided course.