Splay Trees Handout. Last time we discussed amortized analysis of data structures

Similar documents
A Bijective Approach to the Permutational Power of a Priority Queue

Chapter Eight Notes N P U1C8S4-6

Stanford University CS259Q: Quantum Computing Handout 8 Luca Trevisan October 18, 2012

Supplementary information Efficient Enumeration of Monocyclic Chemical Graphs with Given Path Frequencies

The Substring Search Problem

9.1 The multiplicative group of a finite field. Theorem 9.1. The multiplicative group F of a finite field is cyclic.

Math 301: The Erdős-Stone-Simonovitz Theorem and Extremal Numbers for Bipartite Graphs

Chapter 3: Theory of Modular Arithmetic 38

Merging to ordered sequences. Efficient (Parallel) Sorting. Merging (cont.)

Pushdown Automata (PDAs)

Flux. Area Vector. Flux of Electric Field. Gauss s Law

Linear Algebra Math 221

1. Show that the volume of the solid shown can be represented by the polynomial 6x x.

Matrix Colorings of P 4 -sparse Graphs

COMP Parallel Computing SMM (3) OpenMP Case Study: The Barnes-Hut N-body Algorithm

Gauss Law. Physics 231 Lecture 2-1

Solution to HW 3, Ma 1a Fall 2016

Multifrontal sparse QR factorization on the GPU

Lecture 8 - Gauss s Law

Name. Date. Period. Engage Examine the pictures on the left. 1. What is going on in these pictures?

P.7 Trigonometry. What s round and can cause major headaches? The Unit Circle.


2.5 The Quarter-Wave Transformer

Solutions to Problem Set 8

PHYS Summer Professor Caillault Homework Solutions. Chapter 5

A quadratic algorithm for road coloring

10/04/18. P [P(x)] 1 negl(n).

Non-Linear Dynamics Homework Solutions Week 2

Pledge: Signature:

Chapter 19 Webassign Help Problems

Markscheme May 2017 Calculus Higher level Paper 3

Section 8.2 Polar Coordinates

A Tutorial on Multiple Integrals (for Natural Sciences / Computer Sciences Tripos Part IA Maths)

Much that has already been said about changes of variable relates to transformations between different coordinate systems.

Top K Nearest Keyword Search on Large Graphs

ITI Introduction to Computing II

Chapter 6. Self-Adjusting Data Structures

AQI: Advanced Quantum Information Lecture 2 (Module 4): Order finding and factoring algorithms February 20, 2013

gr0 GRAPHS Hanan Samet

The Chromatic Villainy of Complete Multipartite Graphs

Physics 207 Lecture 5. Lecture 5

CS-184: Computer Graphics. Today. Lecture #5: 3D Transformations and Rotations. Wednesday, September 7, 11. Transformations in 3D Rotations

On a quantity that is analogous to potential and a theorem that relates to it

CS-184: Computer Graphics. Today. Lecture #5: 3D Transformations and Rotations. 05-3DTransformations.key - September 21, 2016

Seidel s Trapezoidal Partitioning Algorithm

Then the number of elements of S of weight n is exactly the number of compositions of n into k parts.

COORDINATE TRANSFORMATIONS - THE JACOBIAN DETERMINANT

Section 11. Timescales Radiation transport in stars

3.1 Random variables

Online-routing on the butterfly network: probabilistic analysis

Upward order-preserving 8-grid-drawings of binary trees

6 PROBABILITY GENERATING FUNCTIONS

CHAPTER 25 ELECTRIC POTENTIAL

Electric Field, Potential Energy, & Voltage

CSCE 478/878 Lecture 4: Experimental Design and Analysis. Stephen Scott. 3 Building a tree on the training set Introduction. Outline.

PDF Created with deskpdf PDF Writer - Trial ::

B da = 0. Q E da = ε. E da = E dv

Exploration of the three-person duel

A proof of the binomial theorem

SAMPLE QUIZ 3 - PHYSICS For a right triangle: sin θ = a c, cos θ = b c, tan θ = a b,

We will consider here a DC circuit, made up two conductors ( go and return, or + and - ), with infinitely long, straight conductors.

Unobserved Correlation in Ascending Auctions: Example And Extensions

radians). Figure 2.1 Figure 2.2 (a) quadrant I angle (b) quadrant II angle is in standard position Terminal side Terminal side Terminal side

Physics 121: Electricity & Magnetism Lecture 1

Permutations and Combinations

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Physics Department Physics 8.07: Electromagnetism II September 15, 2012 Prof. Alan Guth PROBLEM SET 2

Plug-and-Play Dual-Tree Algorithm Runtime Analysis

Quantum Fourier Transform

Merging Uncertain Multi-Version XML Documents

Physics 161 Fall 2011 Extra Credit 2 Investigating Black Holes - Solutions The Following is Worth 50 Points!!!

Lab 10: Newton s Second Law in Rotation

Objects usually are charged up through the transfer of electrons from one object to the other.

Homework 1 Solutions CSE 101 Summer 2017

5.61 Physical Chemistry Lecture #23 page 1 MANY ELECTRON ATOMS

MATH 415, WEEK 3: Parameter-Dependence and Bifurcations

Fractional Zero Forcing via Three-color Forcing Games

Section 25 Describing Rotational Motion

Physics 11 Chapter 20: Electric Fields and Forces

History of Astronomy - Part II. Tycho Brahe - An Observer. Johannes Kepler - A Theorist

1 2 U CV. K dq I dt J nqv d J V IR P VI

Physics 107 TUTORIAL ASSIGNMENT #8

Review Exercise Set 16

HASHING METHODS. Hanan Samet

Unit 6 Practice Test. Which vector diagram correctly shows the change in velocity Δv of the mass during this time? (1) (1) A. Energy KE.

Section 26 The Laws of Rotational Motion

Phys102 Second Major-182 Zero Version Monday, March 25, 2019 Page: 1

Encapsulation theory: the transformation equations of absolute information hiding.

Convergence Dynamics of Resource-Homogeneous Congestion Games: Technical Report

CHAPTER 10 ELECTRIC POTENTIAL AND CAPACITANCE

COLLAPSING WALLS THEOREM

SIO 229 Gravity and Geomagnetism. Lecture 6. J 2 for Earth. J 2 in the solar system. A first look at the geoid.

Forest-Like Abstract Voronoi Diagrams in Linear Time

Goodness-of-fit for composite hypotheses.

ELECTROSTATICS::BHSEC MCQ 1. A. B. C. D.

The main paradox of KAM-theory for restricted three-body problem (R3BP, celestial mechanics)

7.2. Coulomb s Law. The Electric Force

Problem 1. Part b. Part a. Wayne Witzke ProblemSet #1 PHY 361. Calculate x, the expected value of x, defined by

Information Retrieval (Relevance Feedback & Query Expansion)

ON INDEPENDENT SETS IN PURELY ATOMIC PROBABILITY SPACES WITH GEOMETRIC DISTRIBUTION. 1. Introduction. 1 r r. r k for every set E A, E \ {0},

Nuclear and Particle Physics - Lecture 20 The shell model

Transcription:

Spla Tees Handout Amotied Analsis Last time we discussed amotied analsis of data stuctues A wa of epessing that even though the wost-case pefomance of an opeation can be bad, the total pefomance of a sequence of opeations cannot be too bad. One wa of thinking of amotied time is as being an aveage : If an sequence of n opeations takes less than T (n) time, the amotied time pe opeation is T (n)/n. We fomall defined amotied time using the idea that we ove-chage some opeations and stoe the ove-chage as cedits/potential that can then help pa fo late opeations (potential method) Conside pefoming n opeations on an initial data stuctue D 0 D i is data stuctue afte ith opeation. c i is actual cost (time) of ith opeation. Potential function: Φ : D i R c i amotied cost of ith opeation: c i = c i + Φ(D i ) Φ(D i ) Given Φ(D 0 ) = 0 and Φ(D i ) 0: n i= c i n i= c i We also discussed two eamples of amotied analsis Stack with Multipop (O(n) wost-case, O() amotied). Incement on bina counte (O(log n) wost-case, O() amotied). In both cases we could ague fo O() amotied pefomance without actuall doing potential calculation we just think about potential/cedits as being distibuted on cetain pats of the data stuctue and let opeations put and take cedits while maintaining some invaiant (accounting method).

Spla tees We have peviousl discussed bina seach tees and how the can be kept balanced (O(log n) height) duing inset and delete opeations (ed-black tees). Rebalancing athe complicated Eta space used fo the colo of each node We also discussed skip lists which ae a lot simple than ed-black tees Onl guaantee O(log n) epected pefomance No eta infomation is used fo ebalance infomation though Spla tees ae seach tees that magicall balance themselves (no ebalance infomation is stoed) and have amotied O(log n) pefomance. Recall seach tees: Bina tee with elements in nodes If node v holds element e then Spla tee: all elements in left subtee < e all elements in left subtee > e Nomal (possibl unbalanced) seach tee T All opeations implemented using one basic opeation, Spla: Spla(, T ) seaches fo in T and eoganies tee such that (o min element > o ma element < ) is in oot Seach(, T ): Spla(, T ) and inspect oot Inset(, T ): Spla(, T ) and ceate new oot with T spla(,t) o

Delete(, T ): Spla(, T ) and emove oot tee falls into T and T. Spla(, T ) Make T ight son of new oot of T afte spla spla(,t) T spla(,) All opeations pefom O() Spla s and use O() eta time. O(log n) amotied Spla gives O(log n) amotied bound on all opeations. Implementation of Spla: Seach fo like in nomal seach tee Repeatedl otate up until it becomes the oot. We distinguish between thee cases:. is child of oot (no gandpaent): otate() e.g. T T. has paent and gandpaent and both and left (ight) childen: otate() followed b otate() Note: Does not wok with otate() and otate() e.g. T T T T T T

. has paent and gandpaent and one of and is a left child and the othe is a ight child: otate() followed b otate() e.g. T T T T T T Note: A Spla can take O(n) wost-case time (ve unbalanced tee) But Spla tees somehow seem to sta nicel balanced Eamples: Spla(, T ) (tpe) (tpe) (tpe) (tpe) Spla(, T ) (tpe) (tpe)

Analsis: We will use accounting method to show that all opeations (Spla) takes O(log n) amotied time. We will imagine that each node in tee has cedits on it We will use some cedits to pa fo (pat of) otations duing a spla We will see that we onl have to place O(log n) new cedits (on oot) when pefoming an Inset o Delete Note that we will ignoe cost of seaching fo, since the otations cost at least as much as the seach ( if we can bound amotied otation cost we also bound seach cost). Let T () be tee ooted at. We will maintain the cedit invaiant that each node holds µ() = log T () cedits. We will pove the following lemma: Less than o equal to (µ(t ) µ()+o()) cedits ae needed to pefom Spla(, T ) opeation and maintain cedit invaiant Using this lemma we get that a spla opeation uses at most log n +O() = O(log n) cedits (time). As an Inset o a Delete equies us to inset at most O(log n) eta cedits (on the oot) moe than the ones used on the Spla, we get the O(log n) amotied bound. Poof of lemma: Case : Let µ and µ be the value of µ befoe and afte a otate opeation in case,, o. Duing a Spla opeation we pefom a numbe of, sa k 0, case and opeations and possibl a case opeation. Net time we will show that the cost of one opeation is: Case : (µ () µ() + O()) Case : (µ () µ()) Case : (µ () µ()) When we sum ove all k + opeations in a spla we get (µ(t ) µ() + O()) whee µ() is the numbe of cedits on befoe the Spla. Note that it is impotant that we onl have the O() tem in case. We have: µ () = µ(), µ () µ () and all othe µ s ae unchanged. To maintain invaiant we use: µ () + µ () µ() µ() = µ () µ() µ () µ() (µ () µ()) To do actual otation we use O() cedits.

Case : We have µ () = µ(), µ () µ (), µ () µ (), µ() µ() and all othe µ s ae unchanged. To maintain invaiant we use: µ () + µ () + µ () µ() µ() µ() = µ () + µ () µ() µ() = (µ () µ()) + (µ () µ()) (µ () µ()) + (µ () µ()) = (µ () µ()) Case : This means that we can use the emaining µ () µ() cedits to pa fo otation, unless µ () = µ() (can happen since µ() = log T () ). We will show that if µ () = µ() then µ () + µ () + µ () < µ() + µ() + µ() which means that the opeation actuall eleases cedits we can use fo the otation: Assume µ () = µ() and µ () + µ () + µ () µ() + µ() + µ() We have µ() = µ () = µ() µ() = µ() = µ() and µ () + µ () + µ () µ() + µ() + µ() = µ() = µ () µ () + µ () µ () Since µ () µ () and µ () µ () we get µ () = µ () = µ () Since µ() = µ () we have µ() = µ() = µ() = µ () = µ () = µ () which cannot be tue (and thus ou initial assumption cannot be tue): Let a be T () befoe otations (a = T + T + ) Let b be T () afte otations (b = T + T + ) Since µ() = µ () = µ () we have log a = log b = log(a + b + ) but then we have the following contadiction: if a b: log(a + b + ) log a = + log a > log a if a > b: log(a + b + ) log b = + log b > log b Can be poved analogousl to case.