Skip Lists. Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015 S 3 S S 1

Similar documents
Skip Lists. What is a Skip List. Skip Lists 3/19/14

Merge and Quick Sort

11. Hash Tables. m is not too large. Many applications require a dynamic set that supports only the directory operations INSERT, SEARCH and DELETE.

Lecture 2: April 3, 2013

Analysis of Algorithms. Introduction. Contents

1 Hash tables. 1.1 Implementation

Disjoint set (Union-Find)

OPTIMAL ALGORITHMS -- SUPPLEMENTAL NOTES

RANDOMIZED ALGORITHMS

Design and Analysis of Algorithms

PH 425 Quantum Measurement and Spin Winter SPINS Lab 1

4.3 Growth Rates of Solutions to Recurrences

Design and Analysis of ALGORITHM (Topic 2)

Skip lists: A randomized dictionary

WHAT IS A SKIP LIST? S 2 S 1. A skip list for a set S of distinct (key, element) items is a series of lists

An Introduction to Randomized Algorithms

CSE 4095/5095 Topics in Big Data Analytics Spring 2017; Homework 1 Solutions

Lecture 2 February 8, 2016

Recursive Algorithms. Recurrences. Recursive Algorithms Analysis

Test One (Answer Key)

CS161 Handout 05 Summer 2013 July 10, 2013 Mathematical Terms and Identities

HOMEWORK 2 SOLUTIONS

SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES

Recurrence Relations

CS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2

19.1 The dictionary problem

ORIE 633 Network Flows September 27, Lecture 8

CS / MCS 401 Homework 3 grader solutions

Lecture 5: April 17, 2013

Lecture 3: August 31

Randomized Algorithms I, Spring 2018, Department of Computer Science, University of Helsinki Homework 1: Solutions (Discussed January 25, 2018)

The standard deviation of the mean

Divide and Conquer. 1 Overview. 2 Multiplying Bit Strings. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016

Probability theory and mathematical statistics:

Sorting Algorithms. Algorithms Kyuseok Shim SoEECS, SNU.

As stated by Laplace, Probability is common sense reduced to calculation.

Axioms of Measure Theory

7.7 Hashing. 7.7 Hashing. Perfect Hashing. Direct Addressing

w (1) ˆx w (1) x (1) /ρ and w (2) ˆx w (2) x (2) /ρ.

Problem Set 2 Solutions

Hashing. Algorithm : Design & Analysis [09]

Definitions: Universe U of keys, e.g., U N 0. U very large. Set S U of keys, S = m U.

Final Review for MATH 3510

Hashing and Amortization

MOST PEOPLE WOULD RATHER LIVE WITH A PROBLEM THEY CAN'T SOLVE, THAN ACCEPT A SOLUTION THEY CAN'T UNDERSTAND.

t distribution [34] : used to test a mean against an hypothesized value (H 0 : µ = µ 0 ) or the difference

1 Statement of the Game

DATA STRUCTURES I, II, III, AND IV

Data Structures Lecture 9

Amortized Analysis - Part 2 - Dynamic Tables. Objective: In this lecture, we shall explore Dynamic tables and its amortized analysis in detail.

Infinite Sequences and Series

Lecture 4: April 10, 2013

A Probabilistic Analysis of Quicksort

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 19

Economics Spring 2015

Advanced Course of Algorithm Design and Analysis

n outcome is (+1,+1, 1,..., 1). Let the r.v. X denote our position (relative to our starting point 0) after n moves. Thus X = X 1 + X 2 + +X n,

ECEN 655: Advanced Channel Coding Spring Lecture 7 02/04/14. Belief propagation is exact on tree-structured factor graphs.

CSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN

Introduction to Probability and Statistics Twelfth Edition

CS284A: Representations and Algorithms in Molecular Biology

CS583 Lecture 02. Jana Kosecka. some materials here are based on E. Demaine, D. Luebke slides

Lecture 4 February 16, 2016

Mathematical Foundation. CSE 6331 Algorithms Steve Lai

Divide and Conquer. 1 Overview. 2 Insertion Sort. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016

Lecture 2. The Lovász Local Lemma

Mathacle. PSet Stats, Concepts In Statistics Level Number Name: Date: Confidence Interval Guesswork with Confidence

Analysis of Algorithms -Quicksort-

Average-Case Analysis of QuickSort

Discrete Mathematics and Probability Theory Spring 2013 Anant Sahai Lecture 18

On Algorithm for the Minimum Spanning Trees Problem with Diameter Bounded Below

Stochastic Matrices in a Finite Field

FACULTY OF MATHEMATICAL STUDIES MATHEMATICS FOR PART I ENGINEERING. Lectures

Element sampling: Part 2

Frequentist Inference

UNIT 2 DIFFERENT APPROACHES TO PROBABILITY THEORY

Introduction to Signals and Systems, Part V: Lecture Summary

Fortgeschrittene Datenstrukturen Vorlesung 11

CS 330 Discussion - Probability

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 17 Lecturer: David Wagner April 3, Notes 17 for CS 170

Lecture 12: September 27

Online hypergraph matching: hiring teams of secretaries

PUTNAM TRAINING PROBABILITY

Discrete Mathematics for CS Spring 2007 Luca Trevisan Lecture 22

CS:3330 (Prof. Pemmaraju ): Assignment #1 Solutions. (b) For n = 3, we will have 3 men and 3 women with preferences as follows: m 1 : w 3 > w 1 > w 2

Putnam Training Exercise Counting, Probability, Pigeonhole Principle (Answers)

The Random Walk For Dummies

Chapter 11: Asking and Answering Questions About the Difference of Two Proportions

Machine Learning Theory (CS 6783)

2 1. The r.s., of size n2, from population 2 will be. 2 and 2. 2) The two populations are independent. This implies that all of the n1 n2

Discrete Mathematics and Probability Theory Summer 2014 James Cook Note 15

Linear chord diagrams with long chords

Advanced Stochastic Processes.

Examples: data compression, path-finding, game-playing, scheduling, bin packing

Homework 3. = k 1. Let S be a set of n elements, and let a, b, c be distinct elements of S. The number of k-subsets of S is

Problems from 9th edition of Probability and Statistical Inference by Hogg, Tanis and Zimmerman:

Matriculation number: You have 90 minutes to complete the exam of InformatikIIb. The following rules apply:

Random Models. Tusheng Zhang. February 14, 2013

It is often useful to approximate complicated functions using simpler ones. We consider the task of approximating a function by a polynomial.

Shannon s noiseless coding theorem

Transcription:

Presetatio for use with the textbook, Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 2015 Skip Lists S 3 15 15 23 10 15 23 36 Skip Lists 1

What is a Skip List A skip list for a set S of distict (key, elemet) items is a series of lists,,, S h such that Each list S i cotais the special keys ad List cotais the keys of S i odecreasig order Each list is a subseuece of the previous oe, i.e., S h List S h cotais oly the two special keys We show how to use a skip list to implemet the map ADT S 3 31 23 31 34 64 12 23 26 31 34 44 56 64 78 Skip Lists 2

Search We search for a key x i a a skip list as follows: We start at the first positio of the top list At the curret positio p, we compare x with y key(ext(p)) x = y: we retur elemet(ext(p)) x > y: we sca forward x < y: we drop dow If we try to drop dow past the bottom list, we retur ull Example: search for 78 S 3 sca forward 31 drop dow 23 31 34 64 12 23 26 31 34 44 56 64 78 Skip Lists 3

Radomized Algorithms A radomized algorithm performs coi tosses (i.e., uses radom bits) to cotrol its executio It cotais statemets of the type b radom() if b = 0 do A else { b = 1} do B Its ruig time depeds o the outcomes of the coi tosses We aalyze the expected ruig time of a radomized algorithm uder the followig assumptios the cois are ubiased, ad the coi tosses are idepedet The worst-case ruig time of a radomized algorithm is ofte large but has very low probability (e.g., it occurs whe all the coi tosses give heads ) We use a radomized algorithm to isert items ito a skip list Skip Lists 4

Isertio To isert a etry (x, o) ito a skip list, we use a radomized algorithm: We repeatedly toss a coi util we get tails, ad we deote with i the umber of times the coi came up heads If i h, we add to the skip list ew lists S h+1,, S i +1, each cotaiig oly the two special keys We search for x i the skip list ad fid the positios p 0, p 1,, p i of the items with largest key less tha x i each list,,, S i For j 0,, i, we isert item (x, o) ito list S j after positio p j Example: isert key 15, with i = 2 p 2 p 1 p 0 10 23 36 23 S 3 15 15 23 10 15 23 36 Skip Lists 5

Deletio To remove a etry with key x from a skip list, we proceed as follows: We search for x i the skip list ad fid the positios p 0, p 1,, p i of the items with key x, where positio p j is i list S j We remove positios p 0, p 1,, p i from the lists,,, S i We remove all but oe list cotaiig oly the two special keys Example: remove key 34 S 3 p 2 34 p 1 23 34 p0 23 12 23 34 45 12 23 45 Skip Lists 6

Implemetatio We ca implemet a skip list with uad-odes A uad-ode stores: etry lik to the ode prev lik to the ode ext lik to the ode below lik to the ode above Also, we defie special keys PLUS_INF ad MINUS_INF, ad we modify the key comparator to hadle them uad-ode x Skip Lists 7

Space Usage The space used by a skip list depeds o the radom bits used by each ivocatio of the isertio algorithm We use the followig two basic probabilistic facts: Fact 1: The probability of gettig i cosecutive heads whe flippig a coi is 1/2 i Fact 2: If each of etries is preset i a set with probability p, the expected size of the set is p Cosider a skip list with etries By Fact 1, we isert a etry i list S i with probability 1/2 i By Fact 2, the expected size of list S i is /2 i The expected umber of odes used by the skip list is h i= 0 h 1 = 2 i < i 2 2 i= 0 Thus, the expected space usage of a skip list with items is O() Skip Lists 8

Height The ruig time of the search a isertio algorithms is affected by the height h of the skip list We show that with high probability, a skip list with items has height O(log ) We use the followig additioal probabilistic fact: Fact 3: If each of evets has probability p, the probability that at least oe evet occurs is at most p Cosider a skip list with etires By Fact 1, we isert a etry i list S i with probability 1/2 i By Fact 3, the probability that list S i has at least oe item is at most /2 i By pickig i = 3log, we have that the probability that S 3log has at least oe etry is at most /2 3log = / 3 = 1/ 2 Thus a skip list with etries has height at most 3log with probability at least 1-1/ 2 Skip Lists 9

Search ad Update Times The search time i a skip list is proportioal to the umber of drop-dow steps, plus the umber of sca-forward steps The drop-dow steps are bouded by the height of the skip list ad thus are O(log ) with high probability To aalyze the sca-forward steps, we use yet aother probabilistic fact: Fact 4: The expected umber of coi tosses reuired i order to get tails is 2 Whe we sca forward i a list, the destiatio key does ot belog to a higher list A sca-forward step is associated with a former coi toss that gave tails By Fact 4, i each list the expected umber of scaforward steps is 2 Thus, the expected umber of sca-forward steps is O(log ) We coclude that a search i a skip list takes O(log ) expected time The aalysis of isertio ad deletio gives similar results Skip Lists 10

Summary A skip list is a data structure for maps that uses a radomized isertio algorithm I a skip list with etries The expected space used is O() The expected search, isertio ad deletio time is O(log ) Usig a more complex probabilistic aalysis, oe ca show that these performace bouds also hold with high probability Skip lists are fast ad simple to implemet i practice Skip Lists 11