Abstract
Describes a module in the Python programming language that implements a “skip list”, a data structure for storing and retrieving sorted elements in O(log n) time.
This publication is available in Web form and also as a PDF document.
Please forward any comments to tcc-doc@nmt.edu.
Table of Contents
SkipList_SkipItem internal class_SkipListIterator classSkipList classSkipList.__init__()SkipList.__estimateLevels()SkipList.insert()SkipList.__keyOf()SkipList.__insertCutList()SkipList.__insertPoint()SkipList.__insertionPrecedes()SkipList.__compareItemKey()SkipList.__insertItem()SkipList.__pickLevel()SkipList.__insertRelink()SkipList.delete()SkipList.__searchCutList()SkipList.__searchPoint()SkipList.__searchPrecedes()SkipList.match()SkipList.__searchCutItemSkipList.find()SkipList.__len__()SkipList.__iter__()SkipList.__contains__()SkipList.__delitem__()SkipList.__getitem__()A skip list is a data structure for representing an ordered set of objects so that insertion and retrieval take minimal time.
This ingenious data structure was described in:
Pugh, William. Skip lists: a probabilistic alternative to balanced trees. In: Communications of the ACM, June 1990, 33(6)668-676.
Like balanced tree structures, skip lists support search whose time complexity varies as the log of the number of elements. However, compared to 2-3 trees and other tree-oriented techniques, skip lists require much simpler algorithms and much less storage overhead within the data structure.
There is also a probabilistic element in the construction of a skip list that makes it an interesting example of the useful of randomness in algorithms.