CSC 252a: Algorithms Pallavi Moorthy 252a-av Smith College December 14, 2000.

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part R4. Disjoint Sets.
1 Union-find. 2 Maintain a collection of disjoint sets under the following two operations S 3 = Union(S 1,S 2 ) Find(x) : returns the set containing x.
Instructor Neelima Gupta Table of Contents Graph Algorithms Thanks to: Sunaina Kalucha (29) (MCS '11)
1 Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 20 Prof. Erik Demaine.
Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm.
Minimum Spanning Tree (MST) form a tree that connects all the vertices (spanning tree). minimize the total edge weight of the spanning tree. Problem Select.
Disjoint-Set Operation
CSE 780 Algorithms Advanced Algorithms Minimum spanning tree Generic algorithm Kruskal’s algorithm Prim’s algorithm.
1 7-MST Minimal Spanning Trees Fonts: MTExtra:  (comment) Symbol:  Wingdings: Fonts: MTExtra:  (comment) Symbol:  Wingdings:
1 Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm.
Minimum Spanning Trees (MST)
CPSC 311, Fall CPSC 311 Analysis of Algorithms Disjoint Sets Prof. Jennifer Welch Fall 2009.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Dynamic Sets and Data Structures Over the course of an algorithm’s execution, an algorithm may maintain a dynamic set of objects The algorithm will perform.
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 17 Union-Find on disjoint sets Motivation Linked list representation Tree representation.
Lecture 16: Union and Find for Disjoint Data Sets Shang-Hua Teng.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
Tirgul 13 Today we’ll solve two questions from last year’s exams.
Minimum Spanning Trees. a b d f g e c a b d f g e c.
CS2420: Lecture 42 Vladimir Kulyukin Computer Science Department Utah State University.
Kruskal’s algorithm for MST and Special Data Structures: Disjoint Sets
1.1 Data Structure and Algorithm Lecture 13 Minimum Spanning Trees Topics Reference: Introduction to Algorithm by Cormen Chapter 13: Minimum Spanning Trees.
David Luebke 1 9/10/2015 ITCS 6114 Single-Source Shortest Path.
Analysis of Algorithms
Definition: Given an undirected graph G = (V, E), a spanning tree of G is any subgraph of G that is a tree Minimum Spanning Trees (Ch. 23) abc d f e gh.
Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm Binary Search Trees1.
Graph Dr. Bernard Chen Ph.D. University of Central Arkansas.
LANWANInternet a b e c d f.
2IL05 Data Structures Fall 2007 Lecture 13: Minimum Spanning Trees.
Spring 2015 Lecture 11: Minimum Spanning Trees
D ESIGN & A NALYSIS OF A LGORITHM 06 – D ISJOINT S ETS Informatics Department Parahyangan Catholic University.
Minimum Spanning Trees and Kruskal’s Algorithm CLRS 23.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Homework remarking requests BEFORE submitting a remarking request: a)read and understand our solution set (which is posted on the course web site) b)read.
Prof. Amr Goneid, AUC1 CSCE 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 9. Disjoint Sets.
1 Greedy Algorithms and MST Dr. Ying Lu RAIK 283 Data Structures & Algorithms.
Disjoint Sets Data Structure (Chap. 21) A disjoint-set is a collection  ={S 1, S 2,…, S k } of distinct dynamic sets. Each set is identified by a member.
Lecture X Disjoint Set Operations
Disjoint Sets Data Structure. Disjoint Sets Some applications require maintaining a collection of disjoint sets. A Disjoint set S is a collection of sets.
Union-find Algorithm Presented by Michael Cassarino.
CSCE 411H Design and Analysis of Algorithms Set 7: Disjoint Sets Prof. Evdokia Nikolova* Spring 2013 CSCE 411H, Spring 2013: Set 7 1 * Slides adapted from.
Disjoint-Set Operation. p2. Disjoint Set Operations : MAKE-SET(x) : Create new set {x} with representative x. UNION(x,y) : x and y are elements of two.
CS 146: Data Structures and Algorithms July 16 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak
Disjoint-sets Abstract Data Type (ADT) that contains nonempty pairwise disjoint sets: For all sets X and Y in the container, – X != ϴ and Y != ϴ – And.
MST – KRUSKAL UNIT IV. Disjoint-Set Union Problem Want a data structure to support disjoint sets – Collection of disjoint sets S = {S i }, S i ∩ S j =
Chapter 23: Minimum Spanning Trees: A graph optimization problem Given undirected graph G(V,E) and a weight function w(u,v) defined on all edges (u,v)
Chapter 21 Data Structures for Disjoint Sets Lee, Hsiu-Hui Ack: This presentation is based on the lecture slides from Prof. Tsai, Shi-Chun as well as various.
1 Week 3: Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm.
David Luebke 1 3/1/2016 CS 332: Algorithms Dijkstra’s Algorithm Disjoint-Set Union.
21. Data Structures for Disjoint Sets Heejin Park College of Information and Communications Hanyang University.
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
MST Lemma Let G = (V, E) be a connected, undirected graph with real-value weights on the edges. Let A be a viable subset of E (i.e. a subset of some MST),
November 22, Algorithms and Data Structures Lecture XII Simonas Šaltenis Nykredit Center for Database Research Aalborg University
CSC 252 Pallavi Moorthy Homework 5. 1.) Vertices, edges From cd../../handout/demo/graph_alg/gw_shortest_path.
Data Structures for Disjoint Sets Manolis Koubarakis Data Structures and Programming Techniques 1.
Tirgul 12 Solving T4 Q. 3,4 Rehearsal about MST and Union-Find
Introduction to Algorithms
Disjoint Sets Data Structure
Graphs and Graph Models
Disjoint Set Neil Tang 02/23/2010
Disjoint Set Neil Tang 02/26/2008
Graph Based Image Segmentation
CS200: Algorithm Analysis
Elementary Graph Algorithms
Kruskal’s Minimum Spanning Tree Algorithm
CSC 413/513: Intro to Algorithms
Minimum Spanning Trees
Review of MST Algorithms Disjoint-Set Union Amortized Analysis
Presentation transcript:

CSC 252a: Algorithms Pallavi Moorthy 252a-av Smith College December 14, 2000

Outline What are disjoint sets? What are disjoint set data structures? Explanation of data structure An application – determining connected components Two representations of disjoint sets: (1) linked lists (2) disjoint set forests

What Are Disjoint Sets? Two sets A and B are disjoint if they have NO elements in common. (A B = 0) U Disjoint Sets NOT Disjoint Sets

What Are Disjoint Set Data Structures? A disjoint-set data structure maintains a collection S = {S1, S2,…,Sk} of disjoint dynamic (changing) sets. Each set has a representative (member of the set). Each element of a set is represented by an object (x).

Why Do We Need Disjoint Set Data Structures? To determine the connected components of an undirected graph.

Operations Supported By Disjoint Set Data Structures MAKE-SET(x): creates a new set with a single member pointed to by x. UNION(x,y): unites the sets that contain common element(s). FIND-SET(x): returns a pointer to the representative of the set containing x.

An Application: Determining the Connected Components of an Undirected Graph CONNECTED-COMPONENTS(G) //computes connected components of a graph 1 for each vertex v in the set V[G] 2 do MAKE-SET(v) 3 for each edge (u,v) in the set E[G] 4do FIND-SET(u) = FIND-SET(v) 5then UNION(u,v) SAME-COMPONENT (u,v) //determines whether two vertices are in the same connected component 1 if FIND-SET(u) = FIND-SET(v) 2then return TRUE 3else return FALSE V[G]= set of vertices of a graph G E[G]=set of edges of a graph G This is the procedure that uses the disjoint set operations to compute the connected components of a graph.

An illustration of how the disjoint sets are computed by CONNECTED- COMPONENTS A graph consisting of four connected components

Linked-list Representation Of Disjoint Sets It’s a simple way to implement a disjoint-set data structure by representing each set, in this case set x, and set y, by a linked list. The total time spent using this representation is Theta(m^2). Set x Set y Result of UNION (x,y)

Disjoint-set Forest Representation It’s a way of representing sets by rooted trees, with each node containing one member, and each tree representing one set. The running time using this representation is linear for all practical purposes but is theoretically superlinear.

Acknowledgements Information and diagrams from Cormen, et al, Chapter 22