Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Skip list
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Implementation details === [[File:Skip list add element-en.gif|thumb|400px|Inserting elements into a skip list]] The elements used for a skip list can contain more than one pointer since they can participate in more than one list. Insertions and deletions are implemented much like the corresponding linked-list operations, except that "tall" elements must be inserted into or deleted from more than one linked list. <math>O(n)</math> operations, which force us to visit every node in ascending order (such as printing the entire list), provide the opportunity to perform a behind-the-scenes derandomization of the level structure of the skip-list in an optimal way, bringing the skip list to <math>O(\log n)</math> search time. (Choose the level of the i'th finite node to be 1 plus the number of times it is possible to repeatedly divide i by 2 before it becomes odd. Also, i=0 for the negative infinity header as there is the usual special case of choosing the highest possible level for negative and/or positive infinite nodes.) However this also allows someone to know where all of the higher-than-level 1 nodes are and delete them. Alternatively, the level structure could be made quasi-random in the following way: make all nodes level 1 j β 1 '''while''' the number of nodes at level j > 1 '''do''' '''for''' each i'th node at level j '''do''' '''if''' i is odd '''and''' i is not the last node at level j randomly choose whether to promote it to level j+1 '''else if''' i is even '''and''' node i-1 was not promoted promote it to level j+1 '''end if''' '''repeat''' j β j + 1 '''repeat''' Like the derandomized version, quasi-randomization is only done when there is some other reason to be running an <math>O(n)</math> operation (which visits every node). The advantage of this quasi-randomness is that it doesn't give away nearly as much level-structure related information to an [[Adversary (online algorithm)|adversarial user]] as the de-randomized one. This is desirable because an adversarial user who is able to tell which nodes are not at the lowest level can pessimize performance by simply deleting higher-level nodes. (Bethea and Reiter however argue that nonetheless an adversary can use probabilistic and timing methods to force performance degradation.<ref>{{cite conference |first1=Darrell |last1=Bethea |first2=Michael K. |last2=Reiter |title=Data Structures with Unpredictable Timing |url=https://www.cs.unc.edu/~djb/papers/2009-ESORICS.pdf#page=5 |at=pp. 456β471, Β§4 "Skip Lists" |doi=10.1007/978-3-642-04444-1_28 |conference=ESORICS 2009, 14th European Symposium on Research in Computer Security |location=Saint-Malo, France |date=September 21β23, 2009 |isbn=978-3-642-04443-4}}</ref>) The search performance is still guaranteed to be logarithmic. It would be tempting to make the following "optimization": In the part which says "Next, for each ''i''th...", forget about doing a coin-flip for each even-odd pair. Just flip a coin once to decide whether to promote only the even ones or only the odd ones. Instead of <math>O(n \log n)</math> coin flips, there would only be <math>O(\log n)</math> of them. Unfortunately, this gives the adversarial user a 50/50 chance of being correct upon guessing that all of the even numbered nodes (among the ones at level 1 or higher) are higher than level one. This is despite the property that there is a very low probability of guessing that a particular node is at level ''N'' for some integer ''N''. A skip list does not provide the same absolute worst-case performance guarantees as more traditional [[balanced tree]] data structures, because it is always possible (though with very low probability<ref>{{cite journal |last1=Sen |first1=Sandeep |title=Some observations on skip lists |journal=Information Processing Letters |date=1991 |volume=39 |issue=4 |pages=173β176 |doi=10.1016/0020-0190(91)90175-H }}</ref>) that the coin-flips used to build the skip list will produce a badly balanced structure. However, they work well in practice, and the randomized balancing scheme has been argued to be easier to implement than the deterministic balancing schemes used in balanced binary search trees. Skip lists are also useful in [[parallel computing]], where insertions can be done in different parts of the skip list in parallel without any global rebalancing of the data structure. Such parallelism can be especially advantageous for resource discovery in an ad-hoc [[wireless network]] because a randomized skip list can be made robust to the loss of any single node.<ref>{{cite thesis |type=Ph.D. thesis | last=Shah | first=Gauri | title=Distributed Data Structures for Peer-to-Peer Systems | year=2003 | url=http://www.cs.yale.edu/homes/shah/pubs/thesis.pdf |publisher=Yale University}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)