Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip Lists -- ever used them? [closed]

I'm wondering whether anyone here has ever used a skip list. It looks to have roughly the same advantages as a balanced binary tree but is simpler to implement. If you have, did you write your own, or use a pre-written library (and if so, what was its name)?

like image 979
Head Geek Avatar asked Oct 24 '08 17:10

Head Geek


People also ask

Where are skip lists used?

Applications of the Skip list. It is used in distributed applications, and it represents the pointers and system in the distributed applications. It is used to implement a dynamic elastic concurrent queue with low lock contention. It is also used with the QMap template class.

Is a skip list like balanced tree *?

Skip lists are a probabilistic alternative to balanced trees. Skip lists are balanced by consulting a random number gen- erator. Although skip lists have bad worst-case performance, no input sequence consistently produces the worst-case per- formance (much like quicksort when the pivot element is cho- sen randomly).

Why do we need skip list?

Skip lists are very useful when you need to be able to concurrently access your data structure. Imagine a red-black tree, an implementation of the binary search tree.

What is deterministic skip list?

The deterministic skip list is a data structure which implements a dynamic ordered dictionary. From now on we shall abbreviate the deterministic skip list as a skip list. The truncated skip list is a skip list in which the height of the skip list is bounded from above by a constant.


2 Answers

My understanding is that they're not so much a useful alternative to binary trees (e.g. red-black trees) as they are to B-trees for database use, so that you can keep the # of levels down to a feasible minimum and deal w/ base-K logs rather than base-2 logs for performance characteristics. The algorithms for probabilistic skip-lists are (IMHO) easier to get right than the corresponding B-tree algorithms. Plus there's some literature on lock-free skip lists. I looked at using them a few months ago but then abandoned the effort on discovering the HDF5 library.

literature on the subject:

Papers by Bill Pugh:

  • A skip list cookbook
  • Skip lists: A probabilistic alternative to balanced trees
  • Concurrent Maintenance of Skip Lists

non-academic papers/tutorials:

  • Eternally Confuzzled (has some discussion on several data structures)
  • "Skip Lists" by Thomas A. Anastasio
like image 160
Jason S Avatar answered Oct 03 '22 16:10

Jason S


Actually, for one of my projects, I am implementing my own full STL. And I used a skiplist to implement my std::map. The reason I went with it is that it is a simple algorithm which is very close to the performance of a balanced tree but has much simpler iteration capabilities.

Also, Qt4's QMap was a skiplist as well which was the original inspiration for my using it in my std::map.

like image 30
Evan Teran Avatar answered Oct 03 '22 17:10

Evan Teran