Search:
We search for an element by traversing forward pointers that do not overshoot the node containing the element being searched for. When no more progress can be made at the current level of forward pointers, the search moves down to the next level. When we can make no more progress at level 1, we must be immediately in front of the node that contains the desired element (if it is in the list).
Insertion and Deletion:
{ x = list header; for (i = list level; i 1; i - -) {
while (x forward[i] key < searchkey)
x = x forward[i];
}
x = x forward[i];
if (x key = searchkey) return (true)
else return false;
}
insert (list, searchkey);
{ x = list header ;
for (i = list level; i 1; i - -) {
while (x forward[i] key < searchkey)
x = x forward[i];
update[i] = x
}
x = x forward[1];
if (x key = searchkey) return (``key already present'')
else {
newLevel = randomLevel();
if newLevel > list level {
for (i = list level + 1; i newLevel; i ++ )
update[i] = list header;
}
x = makenode(newLevel, searchkey);
for (i = 1, i newLevel; i++) {
x forward[i] = update[i] forward[i];
update[i] forward[i] = x
}
}}
delete (list, searchkey);
{ x = list header ;
for (i = list level; i 1; i - ) {
while (x forward[i] key <searchkey)
x = x forward[i];
update[i] = x
}
x = x forward[1];
if (x key = searchkey) {
for (i = 1; i list level; i ++) {
if (update[i] forward[i] x) break;
if (update[i] forward[i] = x forward[i];
}
free(x)
While (( list 1) &&
(list header forward [list+level] = NIL))
list level = list level - 1