Download presentation

Presentation is loading. Please wait.

Published byAidan Baysden Modified over 2 years ago

1
Skip Lists Present By PAKDEE PATTANAJEDSADA SITTHICHOK SNANSIENG SIWAKORN THAMMAYTHA PATOMPOL TAESUJI

2
Outline Introduction ADT Implementation & Complexity – Search – Insert – Remove

3
Introduction “Skip Lists” “Skip Lists” were developed around 1989 by William Pugh of the University of Maryland. Professor Pugh sees Skip Lists as a viable alternative to balanced trees such as AVL trees or to self-adjusting trees such as splay trees. The find, insert, and remove operations on ordinary binary search trees are efficient, when the input data is random; but less efficient, when the input data are ordered. Skip List performance for these same operations and for any data set is about as good as that of randomly-built binary search trees – namely, Skip List performance :

4
Skip Lists are sorted linked lists with two differences: the nodes in an ordinary list have one 'next' reference. The nodes in a Skip List have many 'next' references (called forward references). the number of forward references for a given node is determined probabilistically. We speak of a Skip List node having levels, one level per forward reference. The number of levels in a node is called the size of the node. In an ordinary sorted list, insert, remove, and find operations require sequential traversal of the list. This results in performance per operation. “Skip Lists” allow intermediate nodes in the list to be ``skipped'' during a traversal - resulting in an expected performance of per operation.

5
Skip List - ADT Specialized Method after(p): Return position after p on same level. before(p): Return position before p on same level. below(p): Return position below p on same tower. above(p): Return position above p on same tower. Return null if no position! 5664 31 64 23 S0S0 S1S1 S2S2 S3S3 72

6
Search(x) We search for a key x in a a skip list as follows: – We start at the first position of the top list – At the current position p, we compare x with y key(after(p)) x y: we return element(after(p)) x y: we “scan forward” x y: we “drop down” – If we try to drop down past the bottom list, we return NO_SUCH_KEY Example: search for 78 S0S0 S1S1 S2S2 S3S3 31 64 3134

7
Example of a (perfect)Skip List Complexity The search time in a skip list is proportional to – the number of drop-down steps, plus – the number of scan-forward steps The drop-down steps are bounded by the height of the skip list and thus are O(log n) with high probability Worst Case -> O(n) 5664 31 64 23 S0S0 S1S1 S2S2 S3S3 72

8
To insert an item (x, o) into a skip list, we use a randomized algorithm: – We repeatedly toss a coin until we get tails, and we denote with i the number of times the coin came up heads – If i h, we add to the skip list new lists S h 1, …, S i 1, each containing only the two special keys – We search for x in the skip list and find the positions p 0, p 1, …, p i of the items with largest key less than x in each list S 0, S 1, …, S i – For j 0, …, i, we insert item (x, o) into list S j after position p j Example: insert key 15, with i 2 Insertion 23 S0S0 S1S1 S2S2 S0S0 S1S1 S2S2 S3S3 2315 p0p0 p1p1 p2p2

9
Insertion - Example Consider inserting the value 8 into the skip list below, and assume that the new node is assigned to level 2:

10
Insertion - Example

11

12

13
Insertion – Pseudo code

14
Insertion - Psudocode

15
Deletion(List, keySearch) Logically, deleting a node should be the opposite of insertion. The same basic principles apply: - first we must find the node that precedes the node to be deleted, if any, remembering the nodes containing "pass" pointers - if the succeeding node contains the targeted key value - update the "pass" pointers that point to the target node - delete the targeted node - if necessary, adjust the head node to reduce the number of levels in the list

16
Example Delete of Skip List

17
Example Deletion of Skip List deletion begin with a search, which will probably have cost Θ( log N ).

18
Deletion Code

19
Reference Skip Lists This document was generated using the LaTeX2HTML translator Version 99.1 release (March 30, 1999) LaTeX2HTML Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds. Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.Nikos DrakosRoss Moore The command line arguments were: latex2html -split 0 -no_navigation skip_lists.tex The translation was initiated by Thomas Anastasio on

20
Question & Answer Q&A

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google