{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

SkipLists

# SkipLists - Skip Lists 8:59 AM Outline and Reading What is...

This preview shows pages 1–2. Sign up to view the full content.

4/1/2003 8:59 AM Skip Lists 1 Skip Lists +∞ −∞ S 0 S 1 S 2 S 3 +∞ −∞ 10 36 23 15 +∞ −∞ 15 +∞ −∞ 23 15 4/1/2003 8:59 AM Skip Lists 2 Outline and Reading What is a skip list (§8.4) Operations Search (§8.4.1) Insertion (§8.4.2) Deletion (§8.4.2) Implementation Analysis (§8.4.3) Space usage Search and update times 4/1/2003 8:59 AM Skip Lists 3 What is a Skip List A skip list for a set S of distinct (key, element) items is a series of lists S 0 , S 1 , … , S h such that Each list S i contains the special keys +∞ and −∞ List S 0 contains the keys of S in nondecreasing order Each list is a subsequence of the previous one, i.e., S 0 S 1 S h List S h contains only the two special keys We show how to use a skip list to implement the dictionary ADT 56 64 78 +∞ 31 34 44 −∞ 12 23 26 +∞ −∞ +∞ 31 −∞ 64 +∞ 31 34 −∞ 23 S 0 S 1 S 2 S 3 4/1/2003 8:59 AM Skip Lists 4 Search 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 +∞ −∞ S 0 S 1 S 2 S 3 +∞ 31 −∞ 64 +∞ 31 34 −∞ 23 56 64 78 +∞ 31 34 44 −∞ 12 23 26 4/1/2003 8:59 AM Skip Lists 5 Randomized Algorithms A randomized algorithm performs coin tosses (i.e., uses random bits) to control its execution It contains statements of the type b random () if b = 0 do A … else { b = 1} do B … Its running time depends on the outcomes of the coin

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 2

SkipLists - Skip Lists 8:59 AM Outline and Reading What is...

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

View Full Document
Ask a homework question - tutors are online