Download presentation
Presentation is loading. Please wait.
1
Skip Lists Intuition and Definition –Efficient searching Insertion Other Operations Randomized Analysis Some figures and ideas from Erik Demaine and Shafi Goldwasser (MIT)
2
Intuition for Searching Skip lists are sorted linked lists with levels to speed up search Higher levels can be thought of as an express subway line Think how you would search for 86 efficiently in this 2 level structure
3
How many levels? Suppose we only have 2 levels. What would be the best distribution of nodes in the second level? Suppose we have 3 levels? Suppose we have lg n levels?
4
Example search with lg n levels
5
Insertion? Suppose you now insert 75 into the skip list. How should we do it?
6
Randomized Insertion All elements inserted into bottom level Flip a random coin to determine how high inserted element should go –With probability p, go up another level –Otherwise, stop. With p = ½, –½ the elements are only on the bottom level –¼ of the elements are go up to the second level –1/8 of the elements go up to the third level –…–… Minimum (leftmost) element (or sentinel) always has the highest level.
7
Other Dynamic Set Operations Listall(L) –time to list? Minimum(L)? Maximum(L)? –search time? Successor(L,x)? Predecessor(L,x)? –Search time Delete(L,x) –How? –Time?
8
Search/Insert Analysis Question 1: What is the maximum level in an n-node skip list? Question 2: What is the expected search time for any item in an n-node skip list?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.