12-Skip-Lists

12-Skip-Lists - Algorithms LECTURE 12 Skip Lists Data...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Algorithms L11.1 Professor Ashok Subramanian L ECTURE 12 Skip Lists Data structure Randomized insertion With-high-probability bound Analysis Coin flipping Algorithms
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Algorithms L11.2 Skip lists Simple randomized dynamic search structure Invented by William Pugh in 1989 Easy to implement Maintains a dynamic set of n elements in O (lg n ) time per operation in expectation and with high probability Strong guarantee on tail of distribution of T ( n ) O (lg n ) “almost always”
Background image of page 2
Algorithms L11.3 One linked list Start from simplest data structure: (sorted) linked list Searches take Θ( n ) time in worst case How can we speed up searches? 14 23 34 42 50 59 66 72 79
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Algorithms L11.4 Two linked lists Suppose we had two sorted linked lists (on subsets of the elements) Each element can appear in one or both lists How can we speed up searches? 14 23 34 42 50 59 66 72 79
Background image of page 4
Algorithms L11.5 Two linked lists as a subway I DEA : Express and local subway lines (à la New York City 7th Avenue Line) Express line connects a few of the stations Local line connects all stations Links between lines at common stations 14 23 34 42 50 59 66 72 79 14 34 42 72
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Algorithms L11.6 Searching in two linked lists S EARCH ( x ) : Walk right in top linked list ( L 1 ) until going right would go too far Walk down to bottom linked list ( L 2 ) Walk right in L 2 until element found (or not) 14 23 34 42 50 59 66 72 79 14 34 42 72
Background image of page 6
Algorithms L11.7 Searching in two linked lists E XAMPLE : S EARCH (59) 14 23 34 42 50 59 66 72 79 14 34 42 72 Too far: 59 < 72
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Algorithms L11.8 Design of two linked lists Q UESTION : Which nodes should be in L 1 ? In a subway, the “popular stations” Here we care about worst-case performance Best approach: Evenly space the nodes in L 1 But how many nodes should be in L 1 ? 14 23 34 42 50 59 66 72 79 14 34 42 72
Background image of page 8
Algorithms L11.9 Analysis of two linked lists A NALYSIS : Search cost is roughly Minimized (up to constant factors) when terms are equal 14 23 34 42 50 59 66 72 79 14 34 42 72 1 2 1 L L L + n L n L L = = = 1 2 2 1
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Algorithms L11.10 Analysis of two linked lists A NALYSIS : , Search cost is roughly 14 23 34 42 50 59 66 72 79 14 42 66 n n n n L L L 2 1 2 1 = + = + n L = 1 n L = 2 n n n n
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/29/2011 for the course IT 201 taught by Professor K.v.arya during the Spring '11 term at IIT Kanpur.

Page1 / 31

12-Skip-Lists - Algorithms LECTURE 12 Skip Lists Data...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online