Disjoint Sets { 9} { 1} { 11} Disjoint Sets (cont) Operations. Disjoint Sets (cont) Disjoint Sets (cont) n elements

Similar documents
= 5! 3! 2! = 5! 3! (5 3)!. In general, the number of different groups of r items out of n items (when the order is ignored) is given by n!

Disjoint set (Union-Find)

Auchmuty High School Mathematics Department Sequences & Series Notes Teacher Version

MATH Midterm Solutions

a) The average (mean) of the two fractions is halfway between them: b) The answer is yes. Assume without loss of generality that p < r.

CHAPTER 5 : SERIES. 5.2 The Sum of a Series Sum of Power of n Positive Integers Sum of Series of Partial Fraction Difference Method

By the end of this section you will be able to prove the Chinese Remainder Theorem apply this theorem to solve simultaneous linear congruences

Using Counting Techniques to Determine Probabilities

The Pigeonhole Principle 3.4 Binomial Coefficients

Lower Bounds for Cover-Free Families

BINOMIAL THEOREM An expression consisting of two terms, connected by + or sign is called a

Ch 3.4 Binomial Coefficients. Pascal's Identit y and Triangle. Chapter 3.2 & 3.4. South China University of Technology

BINOMIAL THEOREM NCERT An expression consisting of two terms, connected by + or sign is called a

On a Problem of Littlewood

THE ANALYTIC LARGE SIEVE

Finite q-identities related to well-known theorems of Euler and Gauss. Johann Cigler

4/9/13. Fibonacci Heaps. H.min. H.min. Priority Queues Performance Cost Summary. COMP 160 Algorithms - Tufts University

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

On randomly generated non-trivially intersecting hypergraphs

2012 GCE A Level H2 Maths Solution Paper Let x,

Counting Functions and Subsets

Consider unordered sample of size r. This sample can be used to make r! Ordered samples (r! permutations). unordered sample

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

Using Difference Equations to Generalize Results for Periodic Nested Radicals

EDEXCEL NATIONAL CERTIFICATE UNIT 28 FURTHER MATHEMATICS FOR TECHNICIANS OUTCOME 2- ALGEBRAIC TECHNIQUES TUTORIAL 1 - PROGRESSIONS

EXAMPLES. Leader in CBSE Coaching. Solutions of BINOMIAL THEOREM A.V.T.E. by AVTE (avte.in) Class XI

DANIEL YAQUBI, MADJID MIRZAVAZIRI AND YASIN SAEEDNEZHAD

ICS141: Discrete Mathematics for Computer Science I

( ) 1 Comparison Functions. α is strictly increasing since ( r) ( r ) α = for any positive real number c. = 0. It is said to belong to

MATH /19: problems for supervision in week 08 SOLUTIONS

Conditional Convergence of Infinite Products

CS / MCS 401 Homework 3 grader solutions

Chapter 3: Theory of Modular Arithmetic 38

Progression. CATsyllabus.com. CATsyllabus.com. Sequence & Series. Arithmetic Progression (A.P.) n th term of an A.P.

LESSON 15: COMPOUND INTEREST

Recursion. Algorithm : Design & Analysis [3]

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

Solution. 1 Solutions of Homework 1. Sangchul Lee. October 27, Problem 1.1

Lecture 24: Observability and Constructibility

r, this equation is graphed in figure 1.

Math 104: Homework 2 solutions

Lecture 6: October 16, 2017

Math 166 Week-in-Review - S. Nite 11/10/2012 Page 1 of 5 WIR #9 = 1+ r eff. , where r. is the effective interest rate, r is the annual

This Lecture. Divide and Conquer. Merge Sort: Algorithm. Merge Sort Algorithm. MergeSort (Example) - 1. MergeSort (Example) - 2

4. PERMUTATIONS AND COMBINATIONS

Metric Space Properties

MA541 : Real Analysis. Tutorial and Practice Problems - 1 Hints and Solutions

A note on random minimum length spanning trees

1. By using truth tables prove that, for all statements P and Q, the statement

MA131 - Analysis 1. Workbook 9 Series III

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

SOME ARITHMETIC PROPERTIES OF OVERPARTITION K -TUPLES

MDIV. Multiple divisor functions

Induction: Solutions

Solutions to Tutorial 3 (Week 4)

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

Einstein Classes, Unit No. 102, 103, Vardhman Ring Road Plaza, Vikas Puri Extn., Outer Ring Road New Delhi , Ph. : ,

A Bijective Approach to the Permutational Power of a Priority Queue

Math 2784 (or 2794W) University of Connecticut

If a subset E of R contains no open interval, is it of zero measure? For instance, is the set of irrationals in [0, 1] is of measure zero?

Lecture 12: November 13, 2018

2 Banach spaces and Hilbert spaces

FIXED POINT AND HYERS-ULAM-RASSIAS STABILITY OF A QUADRATIC FUNCTIONAL EQUATION IN BANACH SPACES

Lecture Notes for Analysis Class

Different kinds of Mathematical Induction

Exam 2 CMSC 203 Fall 2009 Name SOLUTION KEY Show All Work! 1. (16 points) Circle T if the corresponding statement is True or F if it is False.

The Boolean Ring of Intervals

Chapter 0. Review of set theory. 0.1 Sets

Electron states in a periodic potential. Assume the electrons do not interact with each other. Solve the single electron Schrodinger equation: KJ =

Lecture 2 February 8, 2016

STAT Homework 1 - Solutions

Math 7409 Homework 2 Fall from which we can calculate the cycle index of the action of S 5 on pairs of vertices as

The number of r element subsets of a set with n r elements

ON EUCLID S AND EULER S PROOF THAT THE NUMBER OF PRIMES IS INFINITE AND SOME APPLICATIONS

REAL ANALYSIS II: PROBLEM SET 1 - SOLUTIONS

KEY. Math 334 Midterm II Fall 2007 section 004 Instructor: Scott Glasgow

Week 5-6: The Binomial Coefficients

SVD ( ) Linear Algebra for. A bit of repetition. Lecture: 8. Let s try the factorization. Is there a generalization? = Q2Λ2Q (spectral theorem!

Bertrand s Postulate

Some Integral Mean Estimates for Polynomials

# fixed points of g. Tree to string. Repeatedly select the leaf with the smallest label, write down the label of its neighbour and remove the leaf.

Assignment 5: Solutions

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

MA131 - Analysis 1. Workbook 3 Sequences II

Analytic Continuation

HOMEWORK #4 - MA 504

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

Ma 530 Introduction to Power Series

University of Colorado Denver Dept. Math. & Stat. Sciences Applied Analysis Preliminary Exam 13 January 2012, 10:00 am 2:00 pm. Good luck!

Complex Numbers Solutions

The Discrete Fourier Transform

Seunghee Ye Ma 8: Week 5 Oct 28

Find a formula for the exponential function whose graph is given , 1 2,16 1, 6

Math 451: Euclidean and Non-Euclidean Geometry MWF 3pm, Gasson 204 Homework 3 Solutions

Homework 1 Solutions. The exercises are from Foundations of Mathematical Analysis by Richard Johnsonbaugh and W.E. Pfaffenberger.

Bertrand s Postulate. Theorem (Bertrand s Postulate): For every positive integer n, there is a prime p satisfying n < p 2n.

Davenport-Schinzel Sequences and their Geometric Applications

Homework 9. (n + 1)! = 1 1

End-of-Year Contest. ERHS Math Club. May 5, 2009

MATHS FOR ENGINEERS ALGEBRA TUTORIAL 8 MATHEMATICAL PROGRESSIONS AND SERIES

Transcription:

Disjoit Sets elemets { x, x, } X =, K Opeatios x Patitioed ito k sets (disjoit sets S, S,, K Fid-Set(x - etu set cotaiig x Uio(x,y - make a ew set by combiig the sets cotaiig x ad y (destoyig them S k 5 0 5 0 MakeSet(x - add a ew elemet x ad make it ito a sigleto set Uio(, Fid-Set( Each set is idetified by its epesetative elemet x 5 0 5 0 {,,5,,,0, } {,,,, } { } { } { } { 0,,5,,, } 5 0 5 0 Fid-Set( Fid-Set( MakeSet(

Vesio Each set is a liked list (with poite to tail List head is the epesetative Each elemet has a poite to the head {,,5,,,0, } {,,,, } { } { } { } { 0,,5,,, } 5 0 Vesio A sequece of m opeatios ca take Θ( m time fo i to m/ MakeSet(i edfo fo i to m/ Uio(i-,i edfo i- i- i- poite updates i m / i = Θ( m 0 5 5 i i- i- Vesio Fid-Set(x - tavese head poite O( MakeSet(x - ceate x O( Vesio (weighted-uio heuistic Modify Vesio by keepig tack of the size of each set ad appedig the smalle to the lage Uio(x,y - Apped S x to S y ad update head poites O( S x 5 0 Each time x s head poite is updated the size of x s set doubles A head poite has bee updated at most lg times if thee ae a total of elemets i the sets A sequece of m istuctios i which thee ae MakeSets takes time O(m + lg

Vesio Each set is a tee with paet poites oly The oot of the tee is the epesetative 0 5 0 5 {,,5,,,0, } {,,,, } { } { } { } { 0,,5,,, } Vesio FidSet(x - Tavese paet poites to each oot (till x=paet(x Wost-case is Θ( 0 5 Fid-Set( 5 0 Vesio MakeSet(x - ceate x O( Uio(x,y - Lik(FidSet(x,FidSet(y 0 5 0 O( + time fo FidSets 5 Uio(, 0 Vesio (weighted-uio ad path compessio MakeSet(x Uio(x,y p(x x FidSet(x ak(x 0 FidSet(y Lik(x,y if Lik(, if ak(x>ak(y FidSet(x the p(y x if x p(x else p(x y the p(x FidSet(p(x if ak(x=ak(y etu(p(x the ak(y++ m MakeSets, FidSets, Uios at most m MakeSets, FidSets, Liks

Vesio FidSet(x - 0 5 Tavese paet poites to each oot (till x=paet(x 0 Fid-Set( 5 Let size(x be the umbe of odes i the subtee ooted at x ak(x Lemma If x is a oot, the size(x Poof: By iductio o the umbe of Lik opeatios Base: 0 Liks All odes ae oots with size ad ak 0 Step: Assume popety holds afte i Liks ad coside the Lik i+, Lik(x,y Case ak(x>ak(y (o vice vesa The ak(x does ot chage ad size(x iceases so iequality still holds Case ak(x=ak(y= The befoe the lik size(x ad size(y + Afte lik ak(y=+ ad size(y + = = ak ( y QED 5 Lemma If x p(x the ak[x]<ak[p(x] Poof: By iductio o the umbe of opeatios Base: 0 opeatios Tivially tue sice o elemets Step: Assume popety holds afte i opeatios ad coside opeatio i+ MakeSet No chage except fo ew ode with x=p(x FidSet If a ode gets a ew paet, it is the oot of its tee ad must have eve highe ak tha the pevious paet Lik The ode that gets a ew paet, gets oe with highe ak QED Lemma Fo ay 0, the # of odes of ak is at most Poof: A ode gets ak as the esult of a Lik of two tees of ak - This ode will have size at least at that time No ode ca cotibute moe tha oce to a ak chage fom - to Sice thee ae odes, at most odes ca attai ak QED Coollay Fo ay ode x, ak( x lg

Fist ty at boudig cost of m istuctios x Maximum cost of a FidSetis O(lg A sequece of m opeatios costs at most O(m lg Ove estimate sice FidSets ae destuctive, educig height of tees Caot fid sequece with Ω(m FidSets each with cost Ω(lg Idea: Boud umbe of paet updates (as i Vesio Befoe FidSet(x Idea: Combie fist ad secod appoaches Thid ty at boudig cost of m istuctios x Afte FidSet(x Chage some paet updates to the ode ad the est to the opeatio Secod ty at boudig cost of m istuctios How may times ca ode x of ak get a ew paet? At most lg - times (Its paets icease i ak fom + to lg The cost of FidSets is at most O(m + # of paet updates lg lg lg # paet updates (lg lg = 0 = 0 = 0 lg + lg lg lg lg lg + lg + = Θ( lg Cost of m opeatios is O(m + lg Ove estimate! Not may baches with cosecutive aks Caot fid Ω( odes with Ω(lg paet updates ak f (k = lg lg - f (i f (i-+ 5 f (0 = 0 f (- = - goup k i 0 goup i has aks i the age [f (i-+, f (i] f ( to be detemied 0

Amotized Aalysis usig Aggegate Method If FidSettaveses odes x, x, K, x p the the cost fo tavesig x is chaged to the ode if x ad p(x ae i the same ak goup (befoe ad p(x is ot the oot Path Chage othewise to the opeatio Block Chage Total cost = total path chages + total block chages Maximum block chages to sigle FidSetis f (lg Maximum block chages to a sequece of m opeatios is ( + m f (lg O m f ( i f ( i = ( 0 = 0 0 f f ( i = N i times f ( j = lg j + f ( i f i = f f ( i = = f ( i f ( (lg = lg (lg + = lg Total cost = total path chages + total block chages ( + m f (lg + f (lg = O( m f (lg O m ( lg O m (lg Amotized Aalysis usig Aggegate Method To boud path chages: If ode x has a paet i a diffeet goup, this will emai the case x i goup i ca be chaged at most f (i-(f (i-+ path chages Total path chages f ( i 0 = f ( i + f ( i f ( i = f ( i + f ( i f ( i ( f ( i ( f ( i + f ( i Time to choose f ( f ( i f ( i