Dec. 09, 2015
Wei Li
Zehao Cai
Ishan Sharma
Time Complexity of Union Find
1Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
Algorithm Definition
Disjoint-set data structure is a data structure that keeps track of a
set of elements partitioned into a number of disjoint (non-overlapping)
subsets.
Union find algorithm
supports three operations on a set of elements:
• MAKE-SET(x). Create a new set containing only element x.
• FIND(x). Return a canonical element in the set containing x.
• UNION(x, y). Merge the sets containing x and y.
Implementation: Linked-list, Tree(Often)
2Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
Find(b) = c | Find(d) = f | Find(b) = f
b → h → c | d → f | b → h → c → f
Quick-find & Quick-union
3Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
Definition: The rank of a node x is similar to the height of x.
When performing the operation Union(x, y), we compare rank(x) and
rank(y):
• If rank(x) < rank(y), make y the parent of x.
• If rank(x) > rank(y), make x the parent of y.
• If rank(x) = rank(y), make y the parent of x and increase the rank of
y by one.
First Optimization: Union By Rank Heuristic
4Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
Note. In this case, rank = height.
During the execution of Find(e), e and all intermediate vertices on
the path from e to the root are made children of the root x.
Second Optimization: Path Compression
5Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
6Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
Union by Rank & Path Compression
This is why we call it “union by rank” rather than “union by height”.
Algorithms Worst-case time
Quick-find 𝑚𝑛
Quick-union 𝑚𝑛
QU + Union by Rank 𝑛 + 𝑚𝑙𝑜𝑔𝑛
QU + Path compression 𝑛 + 𝑚𝑙𝑜𝑔𝑛
QU + Union by rank + Path compression 𝑛 + 𝑚𝑙𝑜𝑔∗
𝑛
m union-find operations on a set of n objects.
Time Complexity
7Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
Lemma 1: as the find function follows the path along to
the root, the rank of node it encounters is increasing
Union: a tree with smaller rank will be attached to a tree with greater
rank, rather than vice versa.
Find: all nodes visited along the path will be attached to the root,
which has larger rank than its children.
8Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
Lemma 2: A node u which is root of a sub-tree with
rank r has at least 2r nodes.
Proof: Initially when each node is the root of its own tree, it's trivially true.
Assume that a node u with rank r has at least 2r nodes. Then when two
tree with rank r Unions by Rank and form a tree with rank r + 1, the new
node has at least 2r + 2r = 2r + 1 nodes.
9Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
Lemma 3: The maximum number of nodes of rank r is
at most n/2r.
Proof: From lemma 2, we know that a node u which is root of a sub-tree
with rank r has at least 2r nodes. We will get the maximum number of nodes
of rank r when each node with rank r is the root of a tree that has exactly 2r
nodes. In this case, the number of nodes of rank r is n / 2r
10Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
We define “bucket” here: a bucket is a set that contains vertices with
particular ranks.
Proof
11Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
𝒍𝒐𝒈∗ 𝒏
𝑙𝑜𝑔∗
𝑛 ∶= .
0																																					𝑖𝑓	𝑛 ≤ 1
1 + 𝑙𝑜𝑔∗
𝑙𝑜𝑔𝑛 										𝑖𝑓	𝑛 > 1
Definition: For all non-negative integer n, 𝑙𝑜𝑔∗
𝑛	is defined as
We have 𝑙𝑜𝑔∗
𝑛 ≤ 5	 unless n exceeds the atoms in the universe.
𝑙𝑜𝑔∗
28
= 1 +	 𝑙𝑜𝑔∗
29
= 1
𝑙𝑜𝑔∗
16 = 𝑙𝑜𝑔∗
2;<
= 1 + 𝑙𝑜𝑔∗
2;
= 3
𝑙𝑜𝑔∗
65536 = 𝑙𝑜𝑔∗
2;<<
= 1 + 𝑙𝑜𝑔∗
2;<
= 4
𝑙𝑜𝑔∗2?@@A? = 𝑙𝑜𝑔∗2;<<<
= 1 + 𝑙𝑜𝑔∗2;<<
= 5
𝑙𝑜𝑔∗
4 = 𝑙𝑜𝑔∗
2;
= 1 +	𝑙𝑜𝑔∗
2 = 2
12Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
We can make two observations about the buckets.
The total number of buckets is at most 𝒍𝒐𝒈∗ 𝒏
Proof: When we go from one bucket to the next, we add one more two
to the power, that is, the next bucket to [B, 2B − 1] will be [2B
,2;D
− 1 ]
The maximum number of elements in bucket [B, 2B – 1] is at
most 𝟐𝒏/𝟐 𝑩
Proof: The maximum number of elements in bucket [B, 2B – 1] is at
most 𝑛 2 𝐵⁄ + 	𝑛 2BK8⁄ +	 𝑛 2BK;⁄ + ⋯ +	𝑛 2;D
M8 ≤ 2𝑛 2B	⁄⁄
Proof
13Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
Let F represent the list of "find" operations performed, and let
Then the total cost of m finds is T = T1 + T2 + T3
Proof
14Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
Proof
15Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
T1 = constant time cost (1) per m operations: O(m)
T2 = maximum number of different buckets: O(𝑚	𝑙𝑜𝑔∗
𝑛)
T3 = for all buckets ( for all notes in one bucket)
= ∑ ∑
O
;P
;D
M8
QRB
STU∗
O
8
	≤ 𝑙𝑜𝑔∗
𝑛		 2B
− 1 − 𝐵
O
;D
					≤ 𝑙𝑜𝑔∗ 𝑛	2B 	
O
;D
= 𝑛	𝑙𝑜𝑔∗
𝑛	
Proof
T = T1 + T2 + T3 = O(m) + O(𝑚𝑙𝑜𝑔∗
𝑛) + O(𝑛𝑙𝑜𝑔∗
𝑛)
𝑚 ≥ 𝑛 → O(𝒎𝒍𝒐𝒈∗
𝒏)
16Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
Algorithms Worst-case time
Quick-find 𝑚𝑛
Quick-union 𝑚𝑛
QU + Union by Rank 𝑛 + 𝑚𝑙𝑜𝑔𝑛
QU + Path compression 𝑛 + 𝑚𝑙𝑜𝑔𝑛
QU + Union by rank + Path compression 𝑛 + 𝑚𝑙𝑜𝑔∗
𝑛
m union-find operations on a set of n objects.
Time Complexity
17Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
Algorithm & Time Complexity
• Simple data structure, algorithm easy to implement.
• Complex to prove time complexity. (Proved in 1975, Tarjan,
Robert Endre )
• Time complexity is near linear.
Applications
• Keep track of the connected components of an undirected
graph;
• Find minimum spanning tree of a graph.
Conclusions
18Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
https://en.wikipedia.org/wiki/Disjoint-set_data_structure
https://en.wikipedia.org/wiki/Proof_of_O(log*n)_time_complexity_of_u
nion%E2%80%93find
http://www.ccse.kfupm.edu.sa/~wasfi/Resources/ICS353CD/Lecture1
7/lec17_slide01.swf
http://sarielhp.org/teach/2004/b/webpage/lec/22_uf.pdf
https://www.cs.princeton.edu/courses/archive/spring13/cos423/lecture
s/UnionFind.pdf
References
19Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015

More Related Content

PPTX
Set Operations - Union Find and Bloom Filters
PPT
Review session2
PPT
5.4 randomized datastructures
PPTX
Graphs, Trees, Paths and Their Representations
PDF
PPT
KRUSKAL'S algorithm from chaitra
PPT
Data structure lecture 2
PDF
Linear sorting
Set Operations - Union Find and Bloom Filters
Review session2
5.4 randomized datastructures
Graphs, Trees, Paths and Their Representations
KRUSKAL'S algorithm from chaitra
Data structure lecture 2
Linear sorting

What's hot (20)

PPT
Chapter 3 ds
PPT
Spanning trees
PPTX
Row major and column major in 2 d
PPT
Arrays and structures
PDF
post119s1-file2
PPTX
Presentation on Elementary data structures
PPT
Data structure
PPTX
Data structures
PPTX
هياكلبيانات
PPT
Fundamentals of data structures
PPTX
Set data structure
PPT
Sparse Matrix and Polynomial
PDF
Answers withexplanations
PPT
K mean-clustering algorithm
PPT
Data structure lecture 3
PDF
PDF
Solution 3.
PDF
Divide and conquer
PPT
Data structure lecture 4
PPTX
Singly & Circular Linked list
Chapter 3 ds
Spanning trees
Row major and column major in 2 d
Arrays and structures
post119s1-file2
Presentation on Elementary data structures
Data structure
Data structures
هياكلبيانات
Fundamentals of data structures
Set data structure
Sparse Matrix and Polynomial
Answers withexplanations
K mean-clustering algorithm
Data structure lecture 3
Solution 3.
Divide and conquer
Data structure lecture 4
Singly & Circular Linked list
Ad

Viewers also liked (20)

PDF
Time complexity of union find
PPTX
NP-Completeness - II
PPTX
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
PPTX
Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and ...
PPTX
Graph Traversal Algorithms - Breadth First Search
PDF
Proof of Cook Levin Theorem (Presentation by Xiechuan, Song and Shuo)
PDF
Stopping Rule for Secretory Problem - Presentation by Haoyang Tian, Wesam Als...
PDF
Bron Kerbosch Algorithm - Presentation by Jun Zhai, Tianhang Qiang and Yizhen...
PPTX
Algorithmic Puzzles
PDF
Arima Forecasting - Presentation by Sera Cresta, Nora Alosaimi and Puneet Mahana
PPTX
Dynamic Programming - Part II
PPTX
NP completeness
PPTX
Dynamic Programming - Part 1
PPTX
Online algorithms in Machine Learning
PPTX
Graph Traversal Algorithms - Depth First Search Traversal
PPTX
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
PPTX
Introduction to Algorithms and Asymptotic Notation
PPTX
Asymptotic Notation and Data Structures
PPTX
Greedy Algorithms
PPTX
Divide and Conquer - Part 1
Time complexity of union find
NP-Completeness - II
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and ...
Graph Traversal Algorithms - Breadth First Search
Proof of Cook Levin Theorem (Presentation by Xiechuan, Song and Shuo)
Stopping Rule for Secretory Problem - Presentation by Haoyang Tian, Wesam Als...
Bron Kerbosch Algorithm - Presentation by Jun Zhai, Tianhang Qiang and Yizhen...
Algorithmic Puzzles
Arima Forecasting - Presentation by Sera Cresta, Nora Alosaimi and Puneet Mahana
Dynamic Programming - Part II
NP completeness
Dynamic Programming - Part 1
Online algorithms in Machine Learning
Graph Traversal Algorithms - Depth First Search Traversal
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Introduction to Algorithms and Asymptotic Notation
Asymptotic Notation and Data Structures
Greedy Algorithms
Divide and Conquer - Part 1
Ad

Similar to Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zehao Cai, Ishan Sharma) (20)

PDF
03-data-structures.pdf
PDF
tree basics to advanced all concepts part 2
PDF
MLSD18. Unsupervised Learning
PDF
Skiena algorithm 2007 lecture09 linear sorting
PDF
Minimum Spanning Trees Artificial Intelligence
PPT
Enhance The K Means Algorithm On Spatial Dataset
PPT
Algo-Exercises-2-hash-AVL-Tree.ppt
PPT
DisjointSetsDisjointSets (1)DisjointSets (1)DisjointSets (1)DisjointSets (1) ...
PPTX
algorithm assignmenteeeeeee.pptx
PPTX
Introduction to Algorithms
PPT
Advanced Data Structures & Algorithm Analysi
PPT
Shell sort[1]
PPTX
Lecture 5_ Sorting and order statistics.pptx
PPTX
Dag representation of basic blocks
PDF
Sienna6bst 120411102353-phpapp02
PPT
Unit-2-Sorting (Merge+Quick+Heap+Binary Searach).ppt
PPT
simple-sorting algorithms
PDF
IRJET- Commuting Graph of Boundedly Generated Regular Semigroup
PPT
PPTX
Chapter-2.pptx
03-data-structures.pdf
tree basics to advanced all concepts part 2
MLSD18. Unsupervised Learning
Skiena algorithm 2007 lecture09 linear sorting
Minimum Spanning Trees Artificial Intelligence
Enhance The K Means Algorithm On Spatial Dataset
Algo-Exercises-2-hash-AVL-Tree.ppt
DisjointSetsDisjointSets (1)DisjointSets (1)DisjointSets (1)DisjointSets (1) ...
algorithm assignmenteeeeeee.pptx
Introduction to Algorithms
Advanced Data Structures & Algorithm Analysi
Shell sort[1]
Lecture 5_ Sorting and order statistics.pptx
Dag representation of basic blocks
Sienna6bst 120411102353-phpapp02
Unit-2-Sorting (Merge+Quick+Heap+Binary Searach).ppt
simple-sorting algorithms
IRJET- Commuting Graph of Boundedly Generated Regular Semigroup
Chapter-2.pptx

More from Amrinder Arora (9)

PPTX
Binomial Heaps and Fibonacci Heaps
PPTX
R-Trees and Geospatial Data Structures
PPTX
Tries - Tree Based Structures for Strings
PPTX
Splay Trees and Self Organizing Data Structures
PPTX
BTrees - Great alternative to Red Black, AVL and other BSTs
PPTX
Binary Search Trees - AVL and Red Black
PPTX
Stacks, Queues, Binary Search Trees - Lecture 1 - Advanced Data Structures
PPTX
Online Algorithms - An Introduction
PPTX
Learning to learn
Binomial Heaps and Fibonacci Heaps
R-Trees and Geospatial Data Structures
Tries - Tree Based Structures for Strings
Splay Trees and Self Organizing Data Structures
BTrees - Great alternative to Red Black, AVL and other BSTs
Binary Search Trees - AVL and Red Black
Stacks, Queues, Binary Search Trees - Lecture 1 - Advanced Data Structures
Online Algorithms - An Introduction
Learning to learn

Recently uploaded (20)

PDF
LIFE & LIVING TRILOGY - PART (3) REALITY & MYSTERY.pdf
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PPTX
DRUGS USED FOR HORMONAL DISORDER, SUPPLIMENTATION, CONTRACEPTION, & MEDICAL T...
PDF
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2013).pdf
PDF
Empowerment Technology for Senior High School Guide
PPTX
Climate Change and Its Global Impact.pptx
PDF
Hazard Identification & Risk Assessment .pdf
PDF
International_Financial_Reporting_Standa.pdf
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PPTX
What’s under the hood: Parsing standardized learning content for AI
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
PDF
HVAC Specification 2024 according to central public works department
PDF
My India Quiz Book_20210205121199924.pdf
PPTX
Education and Perspectives of Education.pptx
PDF
Complications of Minimal Access-Surgery.pdf
PDF
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
LIFE & LIVING TRILOGY - PART (3) REALITY & MYSTERY.pdf
AI-driven educational solutions for real-life interventions in the Philippine...
Share_Module_2_Power_conflict_and_negotiation.pptx
Unit 4 Computer Architecture Multicore Processor.pptx
DRUGS USED FOR HORMONAL DISORDER, SUPPLIMENTATION, CONTRACEPTION, & MEDICAL T...
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2013).pdf
Empowerment Technology for Senior High School Guide
Climate Change and Its Global Impact.pptx
Hazard Identification & Risk Assessment .pdf
International_Financial_Reporting_Standa.pdf
A powerpoint presentation on the Revised K-10 Science Shaping Paper
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
What’s under the hood: Parsing standardized learning content for AI
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
HVAC Specification 2024 according to central public works department
My India Quiz Book_20210205121199924.pdf
Education and Perspectives of Education.pptx
Complications of Minimal Access-Surgery.pdf
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf

Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zehao Cai, Ishan Sharma)

  • 1. Dec. 09, 2015 Wei Li Zehao Cai Ishan Sharma Time Complexity of Union Find 1Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
  • 2. Algorithm Definition Disjoint-set data structure is a data structure that keeps track of a set of elements partitioned into a number of disjoint (non-overlapping) subsets. Union find algorithm supports three operations on a set of elements: • MAKE-SET(x). Create a new set containing only element x. • FIND(x). Return a canonical element in the set containing x. • UNION(x, y). Merge the sets containing x and y. Implementation: Linked-list, Tree(Often) 2Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
  • 3. Find(b) = c | Find(d) = f | Find(b) = f b → h → c | d → f | b → h → c → f Quick-find & Quick-union 3Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
  • 4. Definition: The rank of a node x is similar to the height of x. When performing the operation Union(x, y), we compare rank(x) and rank(y): • If rank(x) < rank(y), make y the parent of x. • If rank(x) > rank(y), make x the parent of y. • If rank(x) = rank(y), make y the parent of x and increase the rank of y by one. First Optimization: Union By Rank Heuristic 4Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015 Note. In this case, rank = height.
  • 5. During the execution of Find(e), e and all intermediate vertices on the path from e to the root are made children of the root x. Second Optimization: Path Compression 5Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
  • 6. 6Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015 Union by Rank & Path Compression This is why we call it “union by rank” rather than “union by height”.
  • 7. Algorithms Worst-case time Quick-find 𝑚𝑛 Quick-union 𝑚𝑛 QU + Union by Rank 𝑛 + 𝑚𝑙𝑜𝑔𝑛 QU + Path compression 𝑛 + 𝑚𝑙𝑜𝑔𝑛 QU + Union by rank + Path compression 𝑛 + 𝑚𝑙𝑜𝑔∗ 𝑛 m union-find operations on a set of n objects. Time Complexity 7Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
  • 8. Lemma 1: as the find function follows the path along to the root, the rank of node it encounters is increasing Union: a tree with smaller rank will be attached to a tree with greater rank, rather than vice versa. Find: all nodes visited along the path will be attached to the root, which has larger rank than its children. 8Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
  • 9. Lemma 2: A node u which is root of a sub-tree with rank r has at least 2r nodes. Proof: Initially when each node is the root of its own tree, it's trivially true. Assume that a node u with rank r has at least 2r nodes. Then when two tree with rank r Unions by Rank and form a tree with rank r + 1, the new node has at least 2r + 2r = 2r + 1 nodes. 9Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
  • 10. Lemma 3: The maximum number of nodes of rank r is at most n/2r. Proof: From lemma 2, we know that a node u which is root of a sub-tree with rank r has at least 2r nodes. We will get the maximum number of nodes of rank r when each node with rank r is the root of a tree that has exactly 2r nodes. In this case, the number of nodes of rank r is n / 2r 10Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
  • 11. We define “bucket” here: a bucket is a set that contains vertices with particular ranks. Proof 11Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
  • 12. 𝒍𝒐𝒈∗ 𝒏 𝑙𝑜𝑔∗ 𝑛 ∶= . 0 𝑖𝑓 𝑛 ≤ 1 1 + 𝑙𝑜𝑔∗ 𝑙𝑜𝑔𝑛 𝑖𝑓 𝑛 > 1 Definition: For all non-negative integer n, 𝑙𝑜𝑔∗ 𝑛 is defined as We have 𝑙𝑜𝑔∗ 𝑛 ≤ 5 unless n exceeds the atoms in the universe. 𝑙𝑜𝑔∗ 28 = 1 + 𝑙𝑜𝑔∗ 29 = 1 𝑙𝑜𝑔∗ 16 = 𝑙𝑜𝑔∗ 2;< = 1 + 𝑙𝑜𝑔∗ 2; = 3 𝑙𝑜𝑔∗ 65536 = 𝑙𝑜𝑔∗ 2;<< = 1 + 𝑙𝑜𝑔∗ 2;< = 4 𝑙𝑜𝑔∗2?@@A? = 𝑙𝑜𝑔∗2;<<< = 1 + 𝑙𝑜𝑔∗2;<< = 5 𝑙𝑜𝑔∗ 4 = 𝑙𝑜𝑔∗ 2; = 1 + 𝑙𝑜𝑔∗ 2 = 2 12Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
  • 13. We can make two observations about the buckets. The total number of buckets is at most 𝒍𝒐𝒈∗ 𝒏 Proof: When we go from one bucket to the next, we add one more two to the power, that is, the next bucket to [B, 2B − 1] will be [2B ,2;D − 1 ] The maximum number of elements in bucket [B, 2B – 1] is at most 𝟐𝒏/𝟐 𝑩 Proof: The maximum number of elements in bucket [B, 2B – 1] is at most 𝑛 2 𝐵⁄ + 𝑛 2BK8⁄ + 𝑛 2BK;⁄ + ⋯ + 𝑛 2;D M8 ≤ 2𝑛 2B ⁄⁄ Proof 13Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
  • 14. Let F represent the list of "find" operations performed, and let Then the total cost of m finds is T = T1 + T2 + T3 Proof 14Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
  • 16. T1 = constant time cost (1) per m operations: O(m) T2 = maximum number of different buckets: O(𝑚 𝑙𝑜𝑔∗ 𝑛) T3 = for all buckets ( for all notes in one bucket) = ∑ ∑ O ;P ;D M8 QRB STU∗ O 8 ≤ 𝑙𝑜𝑔∗ 𝑛 2B − 1 − 𝐵 O ;D ≤ 𝑙𝑜𝑔∗ 𝑛 2B O ;D = 𝑛 𝑙𝑜𝑔∗ 𝑛 Proof T = T1 + T2 + T3 = O(m) + O(𝑚𝑙𝑜𝑔∗ 𝑛) + O(𝑛𝑙𝑜𝑔∗ 𝑛) 𝑚 ≥ 𝑛 → O(𝒎𝒍𝒐𝒈∗ 𝒏) 16Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
  • 17. Algorithms Worst-case time Quick-find 𝑚𝑛 Quick-union 𝑚𝑛 QU + Union by Rank 𝑛 + 𝑚𝑙𝑜𝑔𝑛 QU + Path compression 𝑛 + 𝑚𝑙𝑜𝑔𝑛 QU + Union by rank + Path compression 𝑛 + 𝑚𝑙𝑜𝑔∗ 𝑛 m union-find operations on a set of n objects. Time Complexity 17Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015
  • 18. Algorithm & Time Complexity • Simple data structure, algorithm easy to implement. • Complex to prove time complexity. (Proved in 1975, Tarjan, Robert Endre ) • Time complexity is near linear. Applications • Keep track of the connected components of an undirected graph; • Find minimum spanning tree of a graph. Conclusions 18Wei/Zehao/Ishan CSCI 6212/Arora/Fall 2015