This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: eventually leads to the root. Union(A, B): Change root(A)’s parent to root(B) ±ind(u): ±ollow pointers to the root and output its ID # Path Compression: Reattach all these elements to the root Analysis Union runs in O(1) ±ind: O(n) O(logn) Union(A, B) iF size(A) < size(B) root(A) > root(B) else root(B).size < root(A).size + root(B).size root(B) > root(A) Elements represented as ordered pairs (ID, size) with parent pointers Invariant: ∀ piece A, the “size” component oF (A) counts # oF elts in A 82 Claim: Starting from any element of A, following parent pointers eventually leads to the root(A), in at most 1+log(size(A)) Base Case: Size(A) = 1 Induction Step: Distance from u to root increases only when its piece merges with a piece at least as large. Distance increases by 1 => log(size(A)) increases by ≥ 1 O(m α (n)) [Chazelle, 90s] Minimal spanning tree 83...
View
Full Document
 Spring '08
 KLEINBERG
 Algorithms, Sort, Kruskal's algorithm, Disjointset data structure, parent pointers, root Analysis Union

Click to edit the document details