CSE 241 Algorithms and Data Structures 10/14/2015. Skip Lists

Similar documents
Big O Notation for Time Complexity of Algorithms

Extremal graph theory II: K t and K t,t

1 Notes on Little s Law (l = λw)

BEST LINEAR FORECASTS VS. BEST POSSIBLE FORECASTS

Lecture 9: Polynomial Approximations

1. Solve by the method of undetermined coefficients and by the method of variation of parameters. (4)

COS 522: Complexity Theory : Boaz Barak Handout 10: Parallel Repetition Lemma

STK4080/9080 Survival and event history analysis

ODEs II, Supplement to Lectures 6 & 7: The Jordan Normal Form: Solving Autonomous, Homogeneous Linear Systems. April 2, 2003

Notes 03 largely plagiarized by %khc

Union-Find Partition Structures Goodrich, Tamassia Union-Find 1

CSE 202: Design and Analysis of Algorithms Lecture 16

Moment Generating Function

Union-Find Partition Structures

Online Supplement to Reactive Tabu Search in a Team-Learning Problem

Math 6710, Fall 2016 Final Exam Solutions

Exercise 3 Stochastic Models of Manufacturing Systems 4T400, 6 May

B. Maddah INDE 504 Simulation 09/02/17

λiv Av = 0 or ( λi Av ) = 0. In order for a vector v to be an eigenvector, it must be in the kernel of λi

C(p, ) 13 N. Nuclear reactions generate energy create new isotopes and elements. Notation for stellar rates: p 12

ECE-314 Fall 2012 Review Questions

N! AND THE GAMMA FUNCTION

Ideal Amplifier/Attenuator. Memoryless. where k is some real constant. Integrator. System with memory

Lecture 15 First Properties of the Brownian Motion

th m m m m central moment : E[( X X) ] ( X X) ( x X) f ( x)

SUMMATION OF INFINITE SERIES REVISITED

Solutions to selected problems from the midterm exam Math 222 Winter 2015

F D D D D F. smoothed value of the data including Y t the most recent data.

Outline. simplest HMM (1) simple HMMs? simplest HMM (2) Parameter estimation for discrete hidden Markov models

Calculus Limits. Limit of a function.. 1. One-Sided Limits...1. Infinite limits 2. Vertical Asymptotes...3. Calculating Limits Using the Limit Laws.

MATH 507a ASSIGNMENT 4 SOLUTIONS FALL 2018 Prof. Alexander. g (x) dx = g(b) g(0) = g(b),

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

Using Linnik's Identity to Approximate the Prime Counting Function with the Logarithmic Integral

S n. = n. Sum of first n terms of an A. P is

Department of Mathematical and Statistical Sciences University of Alberta

10.3 Autocorrelation Function of Ergodic RP 10.4 Power Spectral Density of Ergodic RP 10.5 Normal RP (Gaussian RP)

Review Answers for E&CE 700T02

FIXED FUZZY POINT THEOREMS IN FUZZY METRIC SPACE

Fresnel Dragging Explained

Supplement for SADAGRAD: Strongly Adaptive Stochastic Gradient Methods"

The Eigen Function of Linear Systems

OLS bias for econometric models with errors-in-variables. The Lucas-critique Supplementary note to Lecture 17

LIMITS OF FUNCTIONS (I)

Lecture 8 April 18, 2018

A Note on Random k-sat for Moderately Growing k

Conditional Probability and Conditional Expectation

L-functions and Class Numbers

MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.265/15.070J Fall 2013 Lecture 4 9/16/2013. Applications of the large deviation technique

An interesting result about subset sums. Nitu Kitchloo. Lior Pachter. November 27, Abstract

Comparison between Fourier and Corrected Fourier Series Methods

Actuarial Society of India

Comparisons Between RV, ARV and WRV

BAYESIAN ESTIMATION METHOD FOR PARAMETER OF EPIDEMIC SIR REED-FROST MODEL. Puji Kurniawan M

Solution. 1 Solutions of Homework 6. Sangchul Lee. April 28, Problem 1.1 [Dur10, Exercise ]

Mathematical Statistics. 1 Introduction to the materials to be covered in this course

Review Exercises for Chapter 9

Four equations describe the dynamic solution to RBC model. Consumption-leisure efficiency condition. Consumption-investment efficiency condition

Class 36. Thin-film interference. Thin Film Interference. Thin Film Interference. Thin-film interference

A note on deviation inequalities on {0, 1} n. by Julio Bernués*

F.Y. Diploma : Sem. II [AE/CH/FG/ME/PT/PG] Applied Mathematics

Section 8 Convolution and Deconvolution

Pure Math 30: Explained!

arxiv: v3 [math.co] 25 May 2013

14.02 Principles of Macroeconomics Fall 2005

2 f(x) dx = 1, 0. 2f(x 1) dx d) 1 4t t6 t. t 2 dt i)

6/10/2014. Definition. Time series Data. Time series Graph. Components of time series. Time series Seasonal. Time series Trend

LINEAR APPROXIMATION OF THE BASELINE RBC MODEL JANUARY 29, 2013

Dynamic h-index: the Hirsch index in function of time

CLOSED FORM EVALUATION OF RESTRICTED SUMS CONTAINING SQUARES OF FIBONOMIAL COEFFICIENTS

HYPOTHESIS TESTING. four steps

Time Dependent Queuing

David Randall. ( )e ikx. k = u x,t. u( x,t)e ikx dx L. x L /2. Recall that the proof of (1) and (2) involves use of the orthogonality condition.

The analysis of the method on the one variable function s limit Ke Wu

Energy Density / Energy Flux / Total Energy in 1D. Key Mathematics: density, flux, and the continuity equation.

CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay

LINEAR APPROXIMATION OF THE BASELINE RBC MODEL SEPTEMBER 17, 2013

Chemical Engineering 374

Math 2414 Homework Set 7 Solutions 10 Points

xp (X = x) = P (X = 1) = θ. Hence, the method of moments estimator of θ is

TAKA KUSANO. laculty of Science Hrosh tlnlersty 1982) (n-l) + + Pn(t)x 0, (n-l) + + Pn(t)Y f(t,y), XR R are continuous functions.

EEC 483 Computer Organization

Ramsey Theory. Tibor Szabó Extremal Combinatorics, FU Berlin, WiSe pigeons. 1

6.003: Signals and Systems

BE.430 Tutorial: Linear Operator Theory and Eigenfunction Expansion

UNIT 1: ANALYTICAL METHODS FOR ENGINEERS

Math 2142 Exam 1 Review Problems. x 2 + f (0) 3! for the 3rd Taylor polynomial at x = 0. To calculate the various quantities:

Problem Set 4 Due Oct, 12

Economics 8723 Macroeconomic Theory Problem Set 2 Professor Sanjay Chugh Spring 2017

Problems and Solutions for Section 3.2 (3.15 through 3.25)

Notes for Lecture 17-18

Solutions to Problems 3, Level 4

SUPER LINEAR ALGEBRA

Review - Week 10. There are two types of errors one can make when performing significance tests:

t = s D Overview of Tests Two-Sample t-test: Independent Samples Independent Samples t-test Difference between Means in a Two-sample Experiment

Four equations describe the dynamic solution to RBC model. Consumption-leisure efficiency condition. Consumption-investment efficiency condition

SOLUTIONS TO ECE 3084

Spectral Simulation of Turbulence. and Tracking of Small Particles

Calculus BC 2015 Scoring Guidelines

Lecture 15: Three-tank Mixing and Lead Poisoning

Biol. 356 Lab 8. Mortality, Recruitment, and Migration Rates

Transcription:

CSE 41 Algorihms ad Daa Srucures 10/14/015 Skip Liss This hadou gives he skip lis mehods ha we discussed i class. A skip lis is a ordered, doublyliked lis wih some exra poiers ha allow us o jump over muliple odes a oce whe raversig he lis i order. For a complee descripio of skip liss wih some aalysis, see he paper o he subjec by heir iveor, Bill Pugh, i Commuicaios of he ACM 33(6):668 76, Jue 1990. Each ode i a skip lis has a key ad a pillar of some heigh (which varies amog odes). A pillar is a array coaiig pairs of ex ad prev poiers. Every pillar of heigh a leas l is hreaded io a ordered liked lis by he poiers a level l. A skip lis coais wo guard pillars, he head ad ail, which have key values ad + respecively. These pillars are a leas as all as ay ohers i he lis ad so form he edpois of he liked liss a every level. Pillar heighs are chose radomly a he ime of ode iserio from a geomeric disribuio wih parameer p = 1/. This disribuio is characerized by Pr[heigh = ] = ( ) 1 for all 1. You ca geerae geomerically disribued radom umbers by, e.g., repeaedly flippig a ubiased coi ad couig he umber of flips eeded o obai he firs head. Alhough pillars ca i heory be arbirarily all, he probabiliy of creaig a very all pillar is exremely small; for example, here is less ha oe chace i a millio ha a give pillar will have heigh above 0. I he followig code, he procedure RadomHeigh() reurs a heigh accordig o he above geomeric disribuio. The oaio x[l].ex refers o he ex poier for he liked lis a level l of x s pillar. 1 Trivial Operaios The mi, max, succ, ad pred operaios o skip liss are rivial (as hey are for ay ordered lis). Successor ad predecessor ca be obaied for ay ode by followig he ex ad prev liks a he boom (level 0) of is pillar. The mi ad max odes are respecively he successor of he head ad he predecessor of he ail. I is sraighforward o recogize ha, e.g., succ has reached he ed of he lis because i will ecouer he ail ode wih value +. Assumig we keep poiers o he lis head ad ail, all of hese operaios are Θ(1). Deleig a ode x i a skip lis requires ha we ulik is pillar from he liked liss a every level. The pseudocode for his operaio is: Remove(x) for l i 0... x.heigh 1 do splice x ou of liked lis a level l If he pillar o be deleed is of heigh, Remove requires ime Θ(). 1

Norivial Operaios The wo ieresig operaios o a skip lis are Fid ad Iser. I will ake some aalysis o show ha he expeced cos of hese operaios is O(log ); for ow, we jus give he pseudocode. The Fid operaio raverses he lis, as you migh expec, bu i ries o jump over as may odes as possible wih each sep. Liks a higher levels usually jump over more odes ha hose a lower levels (because aller pillars occur less ofe), so we jump as far as we ca a each level before descedig o he level below i. Fid(k) l head.heigh 1 x head while l 0 do y x[l].ex if y.key = k reur y else if y.key < k x y else l reur ull Iserio is oly slighly more ieresig. We eed o iser he ewly allocaed pillar a is correc place i he liked liss for every level. While we could raverse each liked lis separaely sarig from he head ode o fid he righ iserio poi, we ake advaage of he fac ha if a ew ode z should be isered afer a ode x a level l, he z mus also appear afer (hough perhaps o immediaely afer) x a every level below l. Noe ha we should sar he iserio, like he fid, from he op level of he skip lis, o from level 1; oherwise, whe = 1 (half he ime o average), we ed up raversig Θ() odes a level 0 o do he iserio. Iser(z) RadomHeigh allocae a pillar of heigh for z l head.heigh 1 x head while l 0 do y x[l].ex if y.key < z.key x y else if l < lik z io lis a level l bewee x ad y l Oe slighly ricky deail of iserio is ha we migh allocae a ew pillar larger ha he head ad ail pillars. Whe his happes, we ca simply icrease he heigh of he head ad ail o accommodae he ew ode. As for resizable hash ables, i ca be show ha if we double he head ad ail heigh each ime a

icrease is eeded, he cos of relikig he ew pillars io he liss a every level is amorized over a large umber of iserios. 3 Performace Aalysis The performace aalysis of skip liss depeds heavily o he fac ha heir pillar heighs are chose from a geomeric disribuio. There are wo higs o show. Firs, he alles pillar heigh, which upper-bouds he cos of deleio, is oo big; i paricular, i s very likely o be O(log ) for a skip lis of elemes. Secod, a fid operaio i a skip lis o average ispecs a cosa umber of keys per level of he lis; hece, he overall umber of key ispecios per search is also O(log ) o average. 3.1 Average Heigh of Talles Pillar The followig proof of logarihmic expeced heigh is much more precise (ad more complex) ha wha we did i class. I class, we merely showed ha, for some cosa c, pillars of heigh < c log were very likely, while hose of heigh > c log were very ulikely, suggesig ha he ippig poi bewee he wo regimes is he ypical behavior. Le H be he heigh of he alles pillar i a skip lis wih elemes (excludig he head ad ail). Firs, i is o hard o see ha ( ) 1 Pr(H > ). To see his, cosider ha he probabiliy ha H > is he probabiliy ha a leas oe pillar i he lis has heigh >. The laer is upper-bouded by imes he probabiliy ha ay sigle pillar has heigh >. We ow wish o argue ha E[H] = O(log ). By defiiio of expecaio, we have E[H] = Pr(H = ). We spli his sum io several pars, each of which ca be bouded idepedely: E[H] = log =1 For he firs par, we may wrie log =1 For he secod par, we have ha Pr(H = ) + = log +1 =1 = log +1 Pr(H = ) + log Pr(H = ) log log 1. Pr(H = ) = 1. 3 =1 = log +1 Pr(H = ) Pr(H = ) Pr(H > log ) ( ) ( log ) Pr(H = ). (1)

Here, we ve simply plugged i our origial boud o Pr(H > ). Fially, for he hird par, we use he followig sum formula for x < 1: x = x [ ] ( + 1)x x+1 1 x 1 x 1 () (You ca derive his formula yourself i he same way as he formula for x see Appedix A of your ex.) We have ha Pr(H = ) = Pr(H > 1) [ ) ( 1 ( ) ] 1. The hird sep uses our origial upper boud for Pr(H > ), while he fourh uses he fac ha x = x (1 x). (Agai, see Appedix A of your ex.) Pluggig x = 1 io Equaio (), we fid ha ( ) 1 = ( ) 1. Coclude ha [ ( ( ) 1 )] Pr(H = ) ) = ( 1 = o(1). Combiig our bouds for all hree erms of he sum i (1), we coclude ha implyig ha E[H] = O(log ). E[H] log + 1 + o(1), 3. Cosa Expeced Search Time Per Level Cosider a fid operaio i a skip lis. The fid fucio ca be broke dow io a series of raversals a differe levels l of he lis, sarig wih he firs key ispeced a level l ad edig whe a key ispecio causes us o go dow isead of forward. How may keys are ispeced o average a level l? To aalyze his siuaio, we sar by observig ha every key ispeced a level l, excep possibly he las, belogs o a pillar of heigh exacly l + 1 (ha is, a pillar whose maximum level is l). Suppose o, i.e. suppose ha some key k ha is o he las has a associaed pillar p of high > l + 1. If k is he argume o he fid fucio, we kow ha k < k, sice oherwise he level s raversal would ermiae a or before 4

k. Hece, he search will pass pillar p a level l. Bu his meas ha he search would have passed pillar p a a higher level (say, l + 1) as well, sice p is i higher-level chais ad we ever move backwards durig a raversal. Hece, we would o acually ispec p s key a level l. Coclude ha our supposiio is false, ad p mus have heigh exacly l + 1. We ca ow boud he expeced legh of he raversal a level l by askig: how may pillars of heigh exacly l + 1 do you expec o raverse before ecouerig a pillar of heigh > l + 1? Each pillar a level l is geeraed idepedely a radom from a geomeric disribuio wih parameer 1/, ad all have heigh a leas = l + 1. For each such pillar, he chace ha is heigh h exceeds is give by Pr(h > h ) = 1 Pr(h = h ) = 1 1/ = 1/. To see he 1/, cosider ha he decisio o wheher o sop he pillar a heigh or coiue o grow i correspods o a sigle, ubiased coi flip. Now he expeced raversal legh is oe plus he expeced umber E[ ] of pillars of heigh exacly prior o he firs pillar of heigh >. We have probabiliy 1/ ha = 0, i.e. ha we immediaely exceed heigh o he firs ew key. Similarly, = 1 wih probabiliy 1/4, wih probabiliy 1/8, ad so forh. Coclude ha ( ) 1 +1 E[ ] = = 1 ( ) 1 = 1 1/ (1 1/) = 1 1/ (1 1/) = 1. Hece, if we iclude he key ha ermiaes he raversal a level l, he average legh of his raversal is 1 + 1 =. Sice we expec he umber of levels raversed o be O(log ), he oal expeced umber of key ispecios is also O(log ). 5