



















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The Disjoint Sets data structure, including its implementation with find and unionBySize functions, path compression, and analysis. Additionally, it introduces the concept of graphs and their applications, such as the Internet, class hierarchies, and conflict-free exam scheduling.
What you will learn
Typology: Lecture notes
1 / 27
This page cannot be seen from the preview
Don't miss anything!
Data Structures
Wade Fagen-Ulmschneider, Craig Zilles
Disjoint Sets Find int DisjointSets::find(int i) { if ( arr_[i] < 0 ) { return i; } else { return find( arr[i] ); } } 1 2 3 4 void DisjointSets::unionBySize(int root1, int root2) { int newSize = arr_[root1] + arr_[root2]; // If arr_[root1] is less than (more negative), it is the larger set; // we union the smaller set, root2, with root1. if ( arr_[root1] < arr_[root2] ) { arr_[root2] = root1; arr_[root1] = newSize; } // Otherwise, do the opposite: else { arr_[root1] = root2; arr_[root2] = newSize; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Disjoint Sets Analysis The iterated log function: The number of times you can take a log of a number. log(n) = 0 , n ≤ 1 1 + log(log(n)) , n > 1 What is lg( 65536 )*?
Disjoint Sets Analysis In an Disjoint Sets implemented with smart unions and path compression on find : Any sequence of m union and find operations result in the worse case running time of O( ____________ ), where n is the number of items in the Disjoint Sets.
In Review: Data Structures Array
**- Sorted Array
The Internet 2003 The OPTE Project (2003) Map of the entire internet; nodes are routers; edges are connections.
“Rush Hour” Solution Unknown Source Presented by Cinda Heeren, 2016
Wolfram|Alpha's "Personal Analytics“ for Facebook Generated: April 2013 using Wade Fagen-Ulmschneider’s Profile Data
Conflict-Free Final Exam Scheduling Graph Unknown Source Presented by Cinda Heeren, 2016
Class Hierarchy At University of Illinois Urbana-Champaign A. Mori, W. Fagen-Ulmschneider, C. Heeren Graph of every course at UIUC; nodes are courses, edges are prerequisites http://waf.cs.illinois.edu/discovery/class_hi erarchy_at_illinois/