SDSU CS 660: Combinatorial Algorithms

[To Lecture Notes Index]
San Diego State University -- This page last updated October 10, 1995

Contents of SkipLists Lecture

    1. Skip Lists: BST Las Vegas Style
      1. Deleting a Node
      2. Adding a Node
      3. Timing results

Skip Lists: BST Las Vegas Style

Level K node - a node with k forward pointers

In above example we have 1/2k nodes at level k

Need lg(n) levels to act like BST

Let p = be the fraction of the nodes with level j pointers that also have level j + 1 pointers

p = 1/3

Deleting a Node

1. Find the node

2. Remove it
Delete 7

Resultant List

Adding a Node

For a skip list need to select a value for p

1. Select the level of the node

2. Add the node in the proper location

Selecting the level - Theory

Select level k with probability pk
newLevel = 1;
while random() < p do
newLevel = newLevel + 1

Selecting the level - Practice

Let N be an upper bound on the number of nodes in the list

Let MaxLevel =

Let CurrentMax be the highest level currently in the list

newLevel = 1;
while random() < p do
newLevel = newLevel + 1
return min(newLevel, CurrentMax + 1, MaxLevel)
Adding Example, p = 1/3
Add 15

random number generator returns .04 and .672

So level is 2

Resultant List

Timing results

List contains 216 elements

Time does not include memory management time

Paper does not include information about access distribution
Time in msec
AlgorithmSearch Insertion Deletion
Skip List0.051 0.0650.059
non-recursive AVL0.0460.100.085
recursive 2-3 tree0.0540.210.21
bottom-up splay0.490.510.53

Performance relative to Skip List
AlgorithmSearch Insertion Deletion
Skip List1.01.01.0
non-recursive AVL0.911.551.46
recursive 2-3 tree1.053.23.65
bottom-up splay9.67.89.0