Presentation is loading. Please wait.

Presentation is loading. Please wait.

SKIPLISTS A Probabilistic Alternative to Balanced Trees.

Similar presentations


Presentation on theme: "SKIPLISTS A Probabilistic Alternative to Balanced Trees."— Presentation transcript:

1 SKIPLISTS A Probabilistic Alternative to Balanced Trees

2 INTRODUCTION  Search in any BBST (AVL,Red Black, Self Adjusting) is efficient but insertion can take long.  On the others side, in a Linked List, insertion is efficient but serach is always sequential.  The “idea” is to build a super highway with multiple speed lines. When you go in a high sped line you can “skip” fast lost of nodes but you can pass your target, on the other side if you go in a slow line you arrive for sure but you go more slow.

3 INTRODUCTION  Skip lists are a data structure that can be used in place of balanced trees.  Skip lists use probabilistic balancing rather than strictly enforced balancing and as a result the algorithms for insertion and deletion in skip lists are much simpler and significantly faster than equivalent algorithms for balanced trees.

4 What is it?  A Skip List is a Data Structure based on parallel linked lists “discovered” by William Pugh en 1990.  It mayor advantage is that that provides expected O(log n) time for all operations.  At a high level, a skip list is just a sorted, singly linked list with some “shortcuts” (additional pointers that allow to tavel faster.

5 Diego Fernando Salas Arciniegas NIL 27 22 20 10 331 First element Last element 10 key pointers Store info Elements of the list What is it?

6 Chained list with aditional pointers

7 ADVANTAGES  The implementation it’s direct and easier than the balanced tree’s algorithm  The memory requirements are less than the used for balanced trees  Insertion and deletion don’t need to be balanced again.  Insertion, deletion, search and union operations support.

8 DISADVANTAGES  Each node in a Skiplist has an array of forward pointers that link the remote nodes.  The number of pointers ahead in a node its determined by a probabilistic function during insertion; the order its randomized.  We search for an element by traversing forward pointers that do not overshoot the node containing the element being searched for.

9 DESCRIPTION  Each node in a Skiplist has an array of forward pointers that link the remote nodes.  The number of pointers ahead in a node its determined by a probabilistic function during insertion; the order its randomized.  We search for an element by traversing forward pointers that do not overshoot the node containing the element being searched for.

10 DESCRIPTION  When no more progress can be made at the current level of forward pointers, the search moves down to the next level.  When we can make no more progress at level 1, we must be immediately in front of the node that contains the desired element (if it is in the list).

11 SEARCH DIAGRAM

12 SEARCH

13 Diego Fernando Salas Arciniegas NIL 27 22 20 10 331 Example: search the object which key is 20 Start with the top pointer of the head Since it points to 22.> 20 then step-down one level. Again it points to 22.> 20 then step-down one level. Points to 10 < 20 then move forward 22.> 20 then step-down Element 20 found return SEARCH

14 INSERTION

15 DELETION

16 Diego Fernando Salas Arciniegas NIL 27 22 20 10 331 Pointers to “previous” Example: delete the object which key is 20 22 > 20, step-down Store the pointer to where we step-down 22 > 20, step-down Store the pointer to where we step-down 10 <= 20, avanzamos 22 <= 20, step-down Store the pointer to where we step-down 20 <= 20, step-down Store the pointer to where we step-down 20 <= 20, found delete Store the pointer to where we “stop” Store the high of the element to delete 2 DELETION

17 Diego Fernando Salas Arciniega NIL 27 22 10 331 Pointers to “previous” We do not change the element to delete 20 Since the element to delete has high 2 we use the two bottom elements of Pointers to “previous” Fix pointer Delete DELETION

18 LEVEL CHOICE

19 SKIPLISTS vs. OTHERS The times in this table reflect the CPU time on a Sun-3/60 to perform an operation in a data structure containing 2 16 elements with integer keys. The values in parenthesis show the results relative to the skip list time. The times for insertion and deletion do not include the time for memory management

20 CONCLUSIONS From a theoretical point of view, there is no need for skip lists. Balanced trees can do everything that can be done with skip lists and have good worstcase time bounds (unlike skip lists). However, implementing balanced trees is an exacting task and as a result balanced tree algorithms are rarely implemented except as part of a programming assignment in a datastructures class.

21 CONCLUSIONS Skip lists are a simple data structure that can be used in place of balanced trees for most applications. Skip lists algorithms are very easy to implement, extend and modify. Skip lists are about as fast as highly optimized balanced tree algorithms and are substantially faster than casually implemented balanced tree algorithms.

22 BIBLIOGRAPHY  PUGH, William. Skip Lists: A Probabilistic Alternative to Balanced Trees. Lecture Notes In Computer Science: “Proceedings of the Workshop on Algorithms and Data Structures”, Vol. 382, 437 – 449, 1989.  http://iamwww.unibe.ch/~wenger/DA/SkipLi st http://iamwww.unibe.ch/~wenger/DA/SkipLi st  http://www.geocities.com/SiliconValley/Netw ork/1854/skiplist.html http://www.geocities.com/SiliconValley/Netw ork/1854/skiplist.html


Download ppt "SKIPLISTS A Probabilistic Alternative to Balanced Trees."

Similar presentations


Ads by Google