Recitation 13. Minimum Spanning Trees Announcements. SegmentLab has been released, and is due Friday, November 17. It s worth 135 points.

Similar documents
Recitation 11. Graph Contraction and MSTs Announcements. SegmentLab has been released, and is due Friday, April 14. It s worth 135 points.

Recitation 10. Shortest Paths Announcements. ShortLab has been released, and is due Friday afternoon. It s worth 125 points.

Week 11: Minimum Spanning trees

Week 12: Minimum Spanning trees and Shortest Paths

COMP 355 Advanced Algorithms

Recitation 12. Dynamic Programming Announcements. SegmentLab has been released and is due Apr 14.

Minimum-Spanning-Tree problem. Minimum Spanning Trees (Forests) Minimum-Spanning-Tree problem

CS 170 Second Midterm ANSWERS 7 April NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt):

COMP 182: Algorithmic Thinking Prim and Dijkstra: Efficiency and Correctness

G205 Fundamentals of Computer Engineering. CLASS 21, Mon. Nov Stefano Basagni Fall 2004 M-W, 1:30pm-3:10pm

MST worksheet By Jim Xu

23.2 Minimum Spanning Trees

Design and Analysis of Algorithms

Graph Algorithms (part 3 of CSC 282),

CSE 100 Minimum Spanning Trees Prim s and Kruskal

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

Example. Minimum-Cost Spanning Tree. Edge Selection Greedy Strategies. Edge Selection Greedy Strategies

Minimum-Cost Spanning Tree. Example

CSE 21: Mathematics for Algorithms and Systems Analysis

CSC 8301 Design & Analysis of Algorithms: Kruskal s and Dijkstra s Algorithms

10/31/18. About A6, Prelim 2. Spanning Trees, greedy algorithms. Facts about trees. Undirected trees

Spanning Trees, greedy algorithms. Lecture 20 CS2110 Fall 2018

Problem 1. Which of the following is true of functions =100 +log and = + log? Problem 2. Which of the following is true of functions = 2 and =3?

SPANNING TREES. Lecture 21 CS2110 Spring 2016

We ve done. Introduction to the greedy method Activity selection problem How to prove that a greedy algorithm works Fractional Knapsack Huffman coding

COMPSCI 311: Introduction to Algorithms First Midterm Exam, October 3, 2018

Introduction to Parallel & Distributed Computing Parallel Graph Algorithms

Algorithms for Minimum Spanning Trees

Notes on Minimum Spanning Trees. Red Rule: Given a cycle containing no red edges, select a maximum uncolored edge on the cycle, and color it red.

CSE 431/531: Analysis of Algorithms. Greedy Algorithms. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo

Dijkstra s algorithm for shortest paths when no edges have negative weight.

2 A Template for Minimum Spanning Tree Algorithms

Spanning Trees, greedy algorithms. Lecture 22 CS2110 Fall 2017

Graph Algorithms (part 3 of CSC 282),

Minimum cost spanning tree

Minimum Spanning Trees

Minimum Spanning Trees. Minimum Spanning Trees. Minimum Spanning Trees. Minimum Spanning Trees

The minimum cost spanning tree problem

Spanning Trees 4/19/17. Prelim 2, assignments. Undirected trees

Spanning Trees. Lecture 22 CS2110 Spring 2017

COS 226 Lecture 19: Minimal Spanning Trees (MSTs) PFS BFS and DFS examples. Classic algorithms for solving a natural problem

Minimum Spanning Trees

2. True or false: even though BFS and DFS have the same space complexity, they do not always have the same worst case asymptotic time complexity.

Exam 3 Practice Problems

CSC 1700 Analysis of Algorithms: Minimum Spanning Tree

CSE 431/531: Algorithm Analysis and Design (Spring 2018) Greedy Algorithms. Lecturer: Shi Li

15 210: Parallel and Sequential Data Structures and Algorithms

Lecture 4: Graph Algorithms

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Minimum Spanning Trees. CSE 373 Data Structures

CS200: Graphs. Rosen Ch , 9.6, Walls and Mirrors Ch. 14

1 Minimum Spanning Trees (MST) b 2 3 a. 10 e h. j m

Lecture 25 Spanning Trees

The Design of Approximation Algorithms

Minimum Spanning Tree (5A) Young Won Lim 5/11/18

CSC 8301 Design & Analysis of Algorithms: Warshall s, Floyd s, and Prim s algorithms

CSE331 Introduction to Algorithms Lecture 15 Minimum Spanning Trees

Outline. CS38 Introduction to Algorithms. Approximation Algorithms. Optimization Problems. Set Cover. Set cover 5/29/2014. coping with intractibility

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

Advanced Algorithms Class Notes for Monday, October 23, 2012 Min Ye, Mingfu Shao, and Bernard Moret

CSE 638: Advanced Algorithms. Lectures 10 & 11 ( Parallel Connected Components )

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

(Dijkstra s Algorithm) Consider the following positively weighted undirected graph for the problems below: 8 7 b c d h g f

TA: Jade Cheng ICS 241 Recitation Lecture Notes #12 November 13, 2009

UML CS Algorithms Qualifying Exam Fall, 2003 ALGORITHMS QUALIFYING EXAM

DESIGN AND ANALYSIS OF ALGORITHMS GREEDY METHOD

Recitation 13. Priority Queues and Hashing Announcements. PASLLab is due this Friday, May 5. The final exam is on Friday, May 13.

In this chapter, we consider some of the interesting problems for which the greedy technique works, but we start with few simple examples.

CS521 \ Notes for the Final Exam

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

Recitation 1. Scan. 1.1 Announcements. SkylineLab has been released, and is due Friday afternoon. It s worth 125 points.

Graph Theory and Optimization Approximation Algorithms

CS302 - Data Structures using C++

CSE 100: GRAPH ALGORITHMS

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Recitation 1. Scan. 1.1 Announcements. SkylineLab has been released, and is due Friday afternoon. It s worth 125 points.

CSE332: Data Abstractions Lecture 25: Minimum Spanning Trees. Ruth Anderson via Conrad Nied Winter 2015

1 Shortest Paths. 1.1 Breadth First Search (BFS) CS 124 Section #3 Shortest Paths and MSTs 2/13/2018

Spanning Trees. Lecture 20 CS2110 Spring 2015

Contents. CS 124 Final Exam Practice Problem 5/6/17. 1 Format and Logistics 2

Lecture 6 Basic Graph Algorithms

Weighted Graph Algorithms Presented by Jason Yuan

Algorithm Analysis Graph algorithm. Chung-Ang University, Jaesung Lee

The Algorithms of Prim and Dijkstra. Class 19

CHAPTER 13 GRAPH ALGORITHMS

All Shortest Paths. Questions from exercises and exams

Algorithm Computation of a Single Source Shortest Path in a Directed Graph. (SSSP algorithm)

Parallel Graph Algorithms

Algorithms and Theory of Computation. Lecture 5: Minimum Spanning Tree

Graph Contraction. Graph Contraction CSE341T/CSE549T 10/20/2014. Lecture 14

CS 341: Algorithms. Douglas R. Stinson. David R. Cheriton School of Computer Science University of Waterloo. February 26, 2019

Algorithms and Data Structures (INF1) Lecture 15/15 Hua Lu

Algorithms and Theory of Computation. Lecture 5: Minimum Spanning Tree

CS 310 Advanced Data Structures and Algorithms

Decreasing a key FIB-HEAP-DECREASE-KEY(,, ) 3.. NIL. 2. error new key is greater than current key 6. CASCADING-CUT(, )

MST & Shortest Path -Prim s -Djikstra s

A Simple and Practical Linear-Work Parallel Algorithm for Connectivity

Introduction to Algorithms May 14, 2003 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser.

Transcription:

Recitation 13 Minimum Spanning Trees 13.1 Announcements SegmentLab has been released, and is due Friday, November 17. It s worth 135 points. 73

74 RECITATION 13. MINIMUM SPANNING TREES 13.2 Prim s Algorithm Minimum spanning trees are useful for a variety of applications in computer science, such as resource allocation, clustering, and image processing. They exhibit certain greedy properties that allow fast computation. In particular, the light-edge property, or cut property, states that when a graph G = (V, E) has its vertices cut into two partititions (U, V \ U), then the edge with minimum weight that crosses from U into V \ U is in the MST of G. Prim s algorithm allows us to exploit this property to greedily insert edges into the partial MST until the full tree is built. The algorithm performs a priority-first search in a fashion similar to Dijkstra s algorithm. A partial implementation for connected, weighted, undirected graphs is given below. Algorithm 13.1. Prim s Algorithm (Partial) 1 fun Prim G = 2 let 3 fun prim (X,T,Q) = 4 case PQ.deleteMin Q of 5 (NONE, _) 6 (SOME (d,(u,v)),q ) 7 if v X then else 8 let val X = 10 val T = case u of 11 NONE 12 SOME u 13 fun relax (Q,(v,w)) = 14 val Q = iterate relax Q 15 in (N + G (v)) 16 prim (X,T,Q ) 17 end 18 in 1 prim ({},[],PQ.singleton (0,(NONE,0))) 20 end Task 13.2. Complete the implementation above by filling in the blanks. The similarity of Prim s and Dijkstra s algorithms should yield a O(m log n) work and span bound as for Dijkstra s algorithm.

13.2. PRIM S ALGORITHM 75 Task 13.3. In Dijkstra s algorithm, it was possible to terminate the algorithm early when we first reached some vertex t to obtain the shortest path from s to t. Can we make a similar optimization in Prim s algorithm? If so, what is it? Remark 13.4. Just as we generalized DFS to solve problems ranging from connectivity to bridge edges, we see it is possible to generalize Dijkstra s algorithm to obtain BFS, A* search, or Prim s algorithm. How versatile! Since the algorithm is so similar to Dijkstra s algorithm, we would expect the same work and span bounds, or possibly faster using a more advanced heap structure. However, Prim s algorithm has no parallelism, while Borůvka s algorithm does.

76 RECITATION 13. MINIMUM SPANNING TREES 13.3 Borůvka s Algorithm The textbook describes two versions of Borůvka s algorithm: one which performs tree contraction at each round, and another which performs a single round of star contraction at each round. We will be using the latter, since it has better overall span, O(log 2 n) rather than O(log 3 n). Task 13.5. Run Borůvka s algorithm on the following graph. Draw the graph at each round, and identify which edges are MST edges. Use the coin flips specified. 1 6 3 2 3 2 4 7 7 5 4 1 8 4 2 8 3 6 10 8 18 5 Vertices Round 1 2 3 4 5 6 7 8 10 0 H T H T T H T H T T 1 T H T T T H 2 T H T

13.4. ADDITIONAL EXERCISES 77 13.4 Additional Exercises Exercise 13.6. The vertex-joiners selected in any round of Borůvka s algorithm form a forest when no two edge weights are equal. Prove this fact. Hint: a forest, by definition, has no cycles. Exercise 13.7. In graph theory, an independent set is a set of vertices for which no two vertices are neighbors of one another. The maximal independent set (MIS) problem is defined as follows: For a graph (V, E), find an independent set I V such that for all v (V \ I), I {v} is not an independent set. a Design an efficient parallel algorithm based on graph contraction which solves the MIS problem. a The condition that we cannot extend such an independent set I with another vertex is what makes it maximal. There is a closely related problem called maximum independent set where you find the largest possible I. However, this problem turns out to be NP-hard!

78 RECITATION 13. MINIMUM SPANNING TREES.