Skip list notes

Back to Deterministic skip list

This section contains notes on the implementation of the skip-list in Pastel. It helps to understand the corresponding code.

We implement the deterministic 1-2-skip-list, using the array-implementation. From now on, we will refer to this variant as a skip-list.

Equivalent elements

We allow the skip-list to contain equivalent elements, i.e. keys x and y such that !(x < y) and !(y < x). This divides the set of elements in the skip-list into equivalence classes. We let the first element of each equivalence class work as a representative.

Leveling

To avoid degrading the performance of the skip-list because of equivalent elements, we will organize the levels of the skip-list as follows:

We call the levels > 0 skip levels. The idea is that whenever a search is done for an element, the interest is always on the first or the last matching element. When the non-representatives are linked only on the basic level, they are invisible to the skip-levels, and thus we are able to search exclusively in the set of representatives.

Equivalence classes

When a given search is started from a non-representative, we need a way to obtain the representative of its equivalence class in constant time. We could store a link to the representative with each element. However, this would lead to linear complexity updates when a representative is removed from the skip-list. To avoid this, we represent the equivalence classes explicitly. Each equivalence class points to its representative, and each element points to its equivalence class. Thus when a representative is removed, we may simply replace the representative pointer in the equivalence class.

Skip-link storage

bool isPowerOfTwo(integer that)
{
    return (that & (that - 1)) == 0;
}

Alternating skip-lists

Insertion

Insertion algorithm

Removal

Removal from a skip-list works as follows:

References

The probabilistic skip-list was introduced in

Skip Lists: A Probabilistic Alternative to Balanced Trees, W. Pugh, Communications of the ACM, vol. 33, no. 6, June 1990, pp. 668-676.

The deterministic skip-list was introduced in

Deterministic Skip Lists, J. Ian Munro, Thomas Papadakis, Robert Sedgewick, Proceedings of the ACM-SIAM Third Annual Symposium on Discrete Algorithms, January 1992.

The alternating skip-list was introduced in

Alternating Skip Lists, Laurence Marrie, Dr Dobbs Journal, August 2000.