CSE 589 Applied Algorithms Spring 1999 Prim’s Algorithm for MST Load Balance Spanning Tree Hamiltonian Path.

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

Chapter 23 Minimum Spanning Tree
Comp 122, Spring 2004 Greedy Algorithms. greedy - 2 Lin / Devi Comp 122, Fall 2003 Overview  Like dynamic programming, used to solve optimization problems.
CSCE 411H Design and Analysis of Algorithms Set 8: Greedy Algorithms Prof. Evdokia Nikolova* Spring 2013 CSCE 411H, Spring 2013: Set 8 1 * Slides adapted.
Minimum Spanning Trees Definition Two properties of MST’s Prim and Kruskal’s Algorithm –Proofs of correctness Boruvka’s algorithm Verifying an MST Randomized.
CS38 Introduction to Algorithms Lecture 5 April 15, 2014.
CSE 326: Data Structures Disjoint Union/Find Ben Lerner Summer 2007.
Disjoint Union / Find CSE 373 Data Structures Lecture 17.
Minimum Spanning Tree Algorithms
CSE 326: Data Structures Disjoint Union/Find. Equivalence Relations Relation R : For every pair of elements (a, b) in a set S, a R b is either true or.
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
CSE 326: Data Structures Spanning Trees Ben Lerner Summer 2007.
CSE Algorithms Minimum Spanning Trees Union-Find Algorithm
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
CSE 589 Applied Algorithms Course Introduction. CSE Lecture 1 - Spring Instructors Instructor –Richard Ladner –206.
CSE 589 Applied Algorithms Spring Colorability Branch and Bound.
1 Binomial heaps, Fibonacci heaps, and applications.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
9/10/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 8 Greedy Graph.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
I/O-Efficient Graph Algorithms Norbert Zeh Duke University EEF Summer School on Massive Data Sets Århus, Denmark June 26 – July 1, 2002.
SPANNING TREES Lecture 21 CS2110 – Spring
Graph Dr. Bernard Chen Ph.D. University of Central Arkansas.
Chapter 2 Graph Algorithms.
2IL05 Data Structures Fall 2007 Lecture 13: Minimum Spanning Trees.
Spring 2015 Lecture 11: Minimum Spanning Trees
0 Course Outline n Introduction and Algorithm Analysis (Ch. 2) n Hash Tables: dictionary data structure (Ch. 5) n Heaps: priority queue data structures.
1 Trees A tree is a data structure used to represent different kinds of data and help solve a number of algorithmic problems Game trees (i.e., chess ),
Minimum Spanning Trees CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
CSE332: Data Abstractions Lecture 24.5: Interlude on Intractability Dan Grossman Spring 2012.
Minimum-Cost Spanning Tree CS 110: Data Structures and Algorithms First Semester,
Spanning Trees CSIT 402 Data Structures II 1. 2 Two Algorithms Prim: (build tree incrementally) – Pick lower cost edge connected to known (incomplete)
Lecture 19 Greedy Algorithms Minimum Spanning Tree Problem.
Lectures on Greedy Algorithms and Dynamic Programming
Union-Find  Application in Kruskal’s Algorithm  Optimizing Union and Find Methods.
SPANNING TREES Lecture 20 CS2110 – Fall Spanning Trees  Definitions  Minimum spanning trees  3 greedy algorithms (incl. Kruskal’s & Prim’s)
 2004 SDU Lecture 6- Minimum Spanning Tree 1.The Minimum Spanning Tree Problem 2.Greedy algorithms 3.A Generic Algorithm 4.Kruskal’s Algorithm.
Minimum Spanning Trees CSE 373 Data Structures Lecture 21.
Minimum- Spanning Trees
CSE 340: Review (at last!) Measuring The Complexity Complexity is a function of the size of the input O() Ω() Θ() Complexity Analysis “same order” Order.
1 22c:31 Algorithms Minimum-cost Spanning Tree (MST)
Lecture 12 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Greedy Algorithms General principle of greedy algorithm
Chapter 9 : Graphs Part II (Minimum Spanning Trees)
Introduction to Algorithms
Chapter 5 : Trees.
Discrete Mathematicsq
CS 3343: Analysis of Algorithms
Lecture 12 Algorithm Analysis
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Graph Algorithm.
Minimum Spanning Tree.
Minimum Spanning Trees
Lecture 12 Algorithm Analysis
Minimum Spanning Trees
Greedy Algorithms Comp 122, Spring 2004.
CSE 373: Data Structures and Algorithms
Lecture 12 Algorithm Analysis
CSE 373: Data Structures and Algorithms
Lecture 14 Minimum Spanning Tree (cont’d)
CSE 332: Minimum Spanning Trees
More Graphs Lecture 19 CS2110 – Fall 2009.
Presentation transcript:

CSE 589 Applied Algorithms Spring 1999 Prim’s Algorithm for MST Load Balance Spanning Tree Hamiltonian Path

CSE Lecture 3 - Spring Performance of W-Union / PC-Find The time complexity of PC-Find is O(log n). An up tree formed by W-Union of height h has at least 2 h nodes. Inductive Proof. h+1 h Weight(T2) > 2 h (ind. hyp.) Weight(T1) > Weight(T2) > 2 h Weight(T) > 2 h +2 h =2 h+1 T1 T2 T

CSE Lecture 3 - Spring Worst Case for PC-Find n/2 Weighted Unions n/4 Weighted Unions

CSE Lecture 3 - Spring Example of Worst Cast (cont’) After n -1 = n/2 + n/4 + …+ 1 Weighted Unions Find If there are n = 2 k nodes then there are k pointers on the longest path to root.

CSE Lecture 3 - Spring Amortized Complexity For disjoint union / find with weighted union and path compression. –average time per operation is essentially a constant. – worst case time for a PC-Find is O(log n). An individual operation can be costly, but over time the average cost per operation is not.

CSE Lecture 3 - Spring Recall Kruskal Sort the edges by increasing cost; Initialize A to be empty; for each edge {i,j} chosen in increasing order do u := PC-Find(i); v := PC-Find(j); if not(u = v) then add {i,j} to A; W-Union(u,v);

CSE Lecture 3 - Spring Evaluation of Kruskal Let G have n vertices and m edges. Sort the edges - O(m log m). Traverse the sorted edge list doing PC-Finds and W-Unions - O(m  (m,n)). Total time is O(m log m).

CSE Lecture 3 - Spring Prim’s Algorithm We maintain a single tree. For each vertex not in the tree maintain the smallest edge to a vertex in the tree

CSE Lecture 3 - Spring Prim’s Algorithm

CSE Lecture 3 - Spring Prim’s Algorithm

CSE Lecture 3 - Spring Prim’s Algorithm

CSE Lecture 3 - Spring Prim’s Algorithm

CSE Lecture 3 - Spring Prim’s Algorithm

CSE Lecture 3 - Spring Prim’s Algorithm

CSE Lecture 3 - Spring Data Structures for Prim Adjacency Lists - we need to look at all the edges from a newly added vertex. Array for the best edges in or to the tree to cost

CSE Lecture 3 - Spring Data Structures for Prim Priority queue for all edges to the tree (blue edges). –Insert, delete-min, delete (e.g. binary heap) to cost to cost

CSE Lecture 3 - Spring Evaluation of Prim n vertices and m edges. Priority queue O(log n) per operation. O(m) priority queue operations. –An edge is visited when a vertex incident to it joins the tree. Time complexity is O(m log n). Storage complexity is O(m).

CSE Lecture 3 - Spring Kruskal vs Prim Kruskal –Simple –Good with sparse graphs - O(m log m) Prim –More complicated –Perhaps better with dense graphs - O(m log n)

CSE Lecture 3 - Spring Load Balanced Spanning Tree (LBST) Input: An undirected graph G = (V,E) and number k. Output: Determine if there is a spanning tree (V,T) of G with the property that for each vertex v there are at most k edges in T incident to v. If there is such a spanning tree report it. We call such a tree a spanning tree of degree k.

CSE Lecture 3 - Spring Spanning Tree of Degree

CSE Lecture 3 - Spring Spanning Tree of Degree

CSE Lecture 3 - Spring Optimization Version of LBST Input: An undirected graph G = (V,E). Output: A number k and a spanning tree (V,T) of degree k. Furthermore, there is no spanning tree of degree < k.

CSE Lecture 3 - Spring Equivalence of two versions Reporting version can be easily reduced to the optimization version. Optimization version can be reduced to the reporting version by searching. Assume a function LBST(G,k) that returns a spanning tree of degree k if there is one, else returns null. k := 2; repeat T:= LBST(G,k); if T = null then k := k +1 until not(T = null)

CSE Lecture 3 - Spring LBST Decision Problem Input: An undirected graph G = (V,E) and number k. Output: Determine if G has a spanning tree of degree k. We expect a yes/no answer only without reporting a solution if the answer is yes.

CSE Lecture 3 - Spring Classes of Problems Decision Problem: just yes or no. Is there a solution or not. Reporting Problem: yes or no, and if yes then report a solution. Optimization Problem: find a best solution for some notion of best.

CSE Lecture 3 - Spring Hamiltonian Path Decision Problem Input: Undirected Graph G =(V,E). Output: Determine if there is a path in G that visits each node exactly once. Decision problem: Yes or No answer. This is a famous NP-complete problem. NP-complete problems do not appear to have polynomial time algorithms. NP-complete problems are hard to solve!

CSE Lecture 3 - Spring Hamiltonian Path Reducible to Spanning Tree of Degree 2 If there an algorithm to quickly determine if a graph has a spanning tree of degree then there is an algorithm to quickly solve the Hamiltonian path problem. –A spanning tree of degree 2 is a Hamiltonian path! –These problems are essentially the same problem.

CSE Lecture 3 - Spring Hamiltonian Path is Reducible Spanning Tree of Degree k for any k Let G = (V,E) be an undirected graph. We can construct in polynomial time G’ = (V’,E’) with the property that G has a Hamiltonian path if and only if G’ has a spanning tree of degree k. Thus, if there is a polynomial time algorithm for the spanning tree problem then there is also also for the Hamiltonian path problem. But there is likely no such algorithm!

CSE Lecture 3 - Spring HP reducible to LBST of Degree 4 GG’ G has a Hamiltonian Path if and only if G’ has a spanning tree of degree 4.

CSE Lecture 3 - Spring HP reducible to LBST of Degree 4 (2) GG’ G has a Hamiltonian Path if and only if G’ has spanning tree of degree 4.

CSE Lecture 3 - Spring HP Reducible to LBST of Degree 4 (3) G has a Hamiltonian Path if and only if G’ a spanning tree of degree k.

CSE Lecture 3 - Spring HP reducible to LBST of Degree 4 (4) GG’ Key fact: Any spanning tree in G’ must contain all the new edges.