Skip List: formally A skip list for a set S of distinct (key, element) items is a series of lists S0, S1 , … , Sh such that Each list Si contains the special.

Slides:



Advertisements
Similar presentations
© 2004 Goodrich, Tamassia Skip Lists1 S0S0 S1S1 S2S2 S3S
Advertisements

Skip Lists. Outline and Reading What is a skip list (§9.4) – Operations (§9.4.1) – Search – Insertion – Deletion Implementation Analysis (§9.4.2) – Space.
CS 225 Lab #11 – Skip Lists.
The Dictionary ADT: Skip List Implementation
SKIP LISTS Amihood Amir Incorporationg the slides of Goodrich and Tamassia (2004)
Skip Lists Present By PAKDEE PATTANAJEDSADA SITTHICHOK SNANSIENG SIWAKORN THAMMAYTHA PATOMPOL TAESUJI
CSC 172 DATA STRUCTURES. SKIP LISTS Read Weiss
Expected Running Times and Randomized Algorithms Instructor Neelima Gupta
Data Structures Lecture 13 Fang Yu Department of Management Information Systems National Chengchi University Fall 2010.
© 2004 Goodrich, Tamassia Skip Lists1  S0S0 S1S1 S2S2 S3S3    2315.
CSC401 – Analysis of Algorithms Lecture Notes 7 Multi-way Search Trees and Skip Lists Objectives: Introduce multi-way search trees especially (2,4) trees,
Skip Lists Michael Oudshoorn. CS351 Software Engineering (AY05)2 Skip Lists Binary Search Trees: O(log n) –If, and only if, the tree is “balanced” Insertion.
© 2004 Goodrich, Tamassia Selection1. © 2004 Goodrich, Tamassia Selection2 The Selection Problem Given an integer k and n elements x 1, x 2, …, x n, taken.
1 CSC401 – Analysis of Algorithms Lecture Notes 9 Radix Sort and Selection Objectives  Introduce no-comparison-based sorting algorithms: Bucket-sort and.
Selection1. 2 The Selection Problem Given an integer k and n elements x 1, x 2, …, x n, taken from a total order, find the k-th smallest element in this.
Skip Lists1 Skip Lists William Pugh: ” Skip Lists: A Probabilistic Alternative to Balanced Trees ”, 1990  S0S0 S1S1 S2S2 S3S3 
Introduction To Algorithms CS 445 Discussion Session 2 Instructor: Dr Alon Efrat TA : Pooja Vaswani 02/14/2005.
CS 1031 Linked Lists Definition of Linked Lists Examples of Linked Lists Operations on Linked Lists Linked List as a Class Linked Lists as Implementations.
Skip Lists 二○一七年四月二十五日
CSCE 3110 Data Structures & Algorithm Analysis Rada Mihalcea Dictionaries. Reading Weiss Chap. 5, Sec
2/19/2016 3:18 PMSkip Lists1  S0S0 S1S1 S2S2 S3S3    2315.
Skip Lists – Why? BSTs –Worse case insertion, search O(n) –Best case insertion, search O(log n) –Where your run fits in O(n) – O(log n) depends on the.
Maps 1/28/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser,
Quick-Sort 2/18/2018 3:56 AM Selection Selection.
Skip Lists S3   S2   S1   S0  
Sorted Maps © 2014 Goodrich, Tamassia, Goldwasser Skip Lists.
Skip Lists 5/10/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M.
Tables and Dictionaries
Lecture No.43 Data Structures Dr. Sohail Aslam.
Doubly Linked List Review - We are writing this code
Searching an Array: Binary Search
Queues Queues Queues.
Chapter 10 Search Trees 10.1 Binary Search Trees Search Trees
Skip Lists S3 + - S2 + - S1 + - S0 + -
Selection Selection 1 Quick-Sort Quick-Sort 10/30/16 13:52
BBC Microbit.
Skip Lists.
Quick-Sort 11/14/2018 2:17 PM Chapter 4: Sorting    7 9
Quick-Sort 11/19/ :46 AM Chapter 4: Sorting    7 9
Skip Lists S3 + - S2 + - S1 + - S0 + -
Lecture No.07 Data Structures Dr. Sohail Aslam
Chapter 20 Lists, Stacks, Queues, and Priority Queues
SKIP LIST & SKIP GRAPH James Aspnes Gauri Shah
Skip Lists S3 + - S2 + - S1 + - S0 + -
Sorted Maps © 2014 Goodrich, Tamassia, Goldwasser Skip Lists.
Dictionaries < > = /3/2018 8:58 AM Dictionaries
Dictionaries 1/17/2019 7:55 AM Hash Tables   4
Data Structures Lecture 30 Sohail Aslam.
Mutable Data (define mylist (list 1 2 3)) (bind ((new (list 4)))
Parasol Lab, Dept. CSE, Texas A&M University
Quick-Sort 2/23/2019 1:48 AM Chapter 4: Sorting    7 9
Algorithms Lecture #37 Dr. Sohail Aslam.
Quick-Sort 2/25/2019 2:22 AM Quick-Sort     2
Quick-Sort 4/8/ :20 AM Quick-Sort     2 9  9
Algorithms Lecture # 29 Dr. Sohail Aslam.
Quick-Sort 4/25/2019 8:10 AM Quick-Sort     2
Maps 4/25/2019 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser,
Lecture No.02 Data Structures Dr. Sohail Aslam
Chapter 5 Stack (part 1).
CS210- Lecture 17 July 12, 2005 Agenda Collision Handling
Quick-Sort 5/7/2019 6:43 PM Selection Selection.
Algorithms Lecture # 01 Dr. Sohail Aslam.
Quick-Sort 5/25/2019 6:16 PM Selection Selection.
Algorithms Lecture # 02 Dr. Sohail Aslam.
Applications of Arrays
Algorithms Lecture #42 Dr. Sohail Aslam.
Algorithms Lecture # 26 Dr. Sohail Aslam.
Algorithms Lecture # 25 Dr. Sohail Aslam.
Skip List: Implementation
Dictionaries and Hash Tables
Presentation transcript:

Skip List: formally A skip list for a set S of distinct (key, element) items is a series of lists S0, S1 , … , Sh such that Each list Si contains the special keys + and - List S0 contains the keys of S in nondecreasing order Each list is a subsequence of the previous one, i.e., S0  S1  …  Sh List Sh contains only the two special keys End of lecture 39, Start of lecture 40.

Lecture No.40 Data Structure Dr. Sohail Aslam

Skip List: formally S3 S2 S1 S0 + - + - + - + - 31 64 31 34 23 56 64 78 + 31 34 44 - 12 23 26 S0

Skip List: Search We search for a key x 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

Skip List: Search Example: search for 78 S3 S2 S1 S0 + - - + - + 31 + S1 - 23 31 34 64 + S0 - 12 23 26 31 34 44 56 64 78 +

Skip List: Insertion 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 Sh+1, … , Si +1, each containing only the two special keys

Skip List: Insertion To insert an item (x, o) into a skip list, we use a randomized algorithm: (cont) We search for x in the skip list and find the positions p0, p1 , …, pi of the items with largest key less than x in each list S0, S1, … , Si For j  0, …, i, we insert item (x, o) into list Sj after position pj

Skip List: Insertion Example: insert key 15, with i = 2 + - S0 S1 S2 10 36 23 15 p2 S2 - + p1 S1 - 23 + p0 S0 - 10 23 36 +

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.5 // head do A … else // tail do B … Its running time depends on the outcomes of the coin tosses, i.e, head or tail

Skip List: Deletion To remove an item with key x from a skip list, we proceed as follows: We search for x in the skip list and find the positions p0, p1 , …, pi of the items with key x, where position pj is in list Sj We remove positions p0, p1 , …, pi from the lists S0, S1, … , Si We remove all but one list containing only the two special keys

Skip List: Deletion Example: remove key 34 S3 - + p2 S2 - + S0 S1 45 12 23 S0 S1 S2 - 34 + p1 S1 - 23 34 + p0 End of lecture 40. S0 - 12 23 34 45 +