Quiz 2 CS 3510 October 22, 2004

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

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

Minimum Spanning Trees

Pred 8 1. Dist. Pred

CIS 121 Data Structures and Algorithms Minimum Spanning Trees

6.1 Minimum Spanning Trees

CS161 - Minimum Spanning Trees and Single Source Shortest Paths

Week 12: Minimum Spanning trees and Shortest Paths

Question Points Score TOTAL 50

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 7 Lecturer: David Wagner February 13, Notes 7 for CS 170

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 8 Lecturer: David Wagner February 20, Notes 8 for CS 170

2.1 Greedy Algorithms. 2.2 Minimum Spanning Trees. CS125 Lecture 2 Fall 2016

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

Exam 3 Practice Problems

Graph Algorithms (part 3 of CSC 282),

Analysis of Algorithms, I

Algorithms (VII) Yijia Chen Shanghai Jiaotong University

Problem Set 6 Solutions

Algorithms (VII) Yijia Chen Shanghai Jiaotong University

CS 310 Advanced Data Structures and Algorithms

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

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

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?

Week 11: Minimum Spanning trees

Questions Total Points Score

Graph Algorithms (part 3 of CSC 282),

Description of The Algorithm

CS Algorithms and Complexity

22 Elementary Graph Algorithms. There are two standard ways to represent a

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

Data Structures Brett Bernstein

COL351: Analysis and Design of Algorithms (CSE, IITD, Semester-I ) Name: Entry number:

Unit #9: Graphs. CPSC 221: Algorithms and Data Structures. Will Evans 2012W1

UNIT 3. Greedy Method. Design and Analysis of Algorithms GENERAL METHOD

Info 2950, Lecture 16

Algorithm Design, Anal. & Imp., Homework 4 Solution

Algorithm Design and Analysis

Solution. violating the triangle inequality. - Initialize U = {s} - Add vertex v to U whenever DIST[v] decreases.

Lecture 5: Graph algorithms 1

Algorithms for Minimum Spanning Trees

Problem Score Maximum MC 34 (25/17) = 50 Total 100

CSE 101. Algorithm Design and Analysis Miles Jones Office 4208 CSE Building Lecture 5: SCC/BFS

CS170 Discussion Section 4: 9/18

Breadth-First Search, 1. Slides for CIS 675 DPV Chapter 4. Breadth-First Search, 3. Breadth-First Search, 2

CS Final - Review material

Three Graph Algorithms

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

Three Graph Algorithms

The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value

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

CSE548, AMS542: Analysis of Algorithms, Fall 2012 Date: October 16. In-Class Midterm. ( 11:35 AM 12:50 PM : 75 Minutes )

These are not polished as solutions, but ought to give a correct idea of solutions that work. Note that most problems have multiple good solutions.

Dr. Alexander Souza. Winter term 11/12

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

The minimum spanning tree problem

Undirected Graphs. DSA - lecture 6 - T.U.Cluj-Napoca - M. Joldos 1

Quiz 2 Practice Problems

22 Elementary Graph Algorithms. There are two standard ways to represent a

Introduction to Algorithms November 28, 2007 Massachusetts Institute of Technology Fall 2007 Professors Ron Rivest and Srini Devadas Quiz 2

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

Fundamental Algorithms CSCI-GA /Summer Solution to Homework 8

CISC 320 Midterm Exam

Question Points Score TOTAL 55 TOTAL (Calibrated) 50

CS483 Design and Analysis of Algorithms

Announcements. HW4 due Friday. Summer 2016 CSE373: Data Structures & Algorithms 1

Algorithms for Data Science

Homework 2 Solutions

Topological Sort. Version of October 11, Version of October 11, 2014 Topological Sort 1 / 14

CSE331 Introduction to Algorithms Lecture 15 Minimum Spanning Trees

Graph Representations and Traversal

Algorithms (VI) Greedy Algorithms. Guoqiang Li. School of Software, Shanghai Jiao Tong University

CS2 Algorithms and Data Structures Note 10. Depth-First Search and Topological Sorting

CSE 101. Algorithm Design and Analysis Miles Jones Office 4208 CSE Building Lecture 8: Negative Edges

CS 125 Section #6 Graph Traversal and Linear Programs 10/13/14

1 Start with each vertex being its own component. 2 Merge two components into one by choosing the light edge

Minimum Spanning Trees

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms

CS420/520 Algorithm Analysis Spring 2009 Lecture 14

Strongly Connected Components. Andreas Klappenecker

Outline. Computer Science 331. Analysis of Prim's Algorithm

Midterm 1 Solutions. (i) False. One possible counterexample is the following: n n 3

CSC 373 Lecture # 3 Instructor: Milad Eftekhar

CSE373: Data Structures & Algorithms Lecture 17: Minimum Spanning Trees. Dan Grossman Fall 2013

Total Score /1 /20 /41 /15 /23 Grader

Homework Assignment #3 Graph

Directed Graphs. DSA - lecture 5 - T.U.Cluj-Napoca - M. Joldos 1

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

CSE 100 Minimum Spanning Trees Prim s and Kruskal

CIS 121 Data Structures and Algorithms Midterm 3 Review Solution Sketches Fall 2018

Algorithms and Data Structures 2014 Exercises and Solutions Week 9

Quiz 2. Problem Parts Points Grade Grader. Total 120. Name: Recitation: Jayant 12 PM. Christina 10 AM. Jayant 1 PM. Jason 2 PM.

Algorithms (V) Path in Graphs. Guoqiang Li. School of Software, Shanghai Jiao Tong University

CS521 \ Notes for the Final Exam

Introduction to Algorithms April 16, 2008 Massachusetts Institute of Technology Spring 2008 Professors Srini Devadas and Erik Demaine Quiz 2

Graph Applications. Topological Sort Shortest Path Problems Spanning Trees. Data Structures 1 Graph Applications

CSci 231 Final Review

Design and Analysis of Algorithms - - Assessment

Strongly Connected Components

CS490 Quiz 1. This is the written part of Quiz 1. The quiz is closed book; in particular, no notes, calculators and cell phones are allowed.

Transcription:

Quiz 2 CS 3510 October 22, 2004 NAME : (Remember to fill in your name!) For grading purposes, please leave blank: (1) Short Answer (40 points) (2) Cycle Length (20 points) (3) Bottleneck (20 points) (4) 0-1 MST (20 points) (Remember to correctly answer all 4 questions!) 1

Name: 2 Let G = (V, E) be an undirected connected graph with distinct non-negative costs on its edges, and which contains at least n edges. Problem 2(a). [5 points] Let e min be the lowest cost edge, in other words: For all e E, cost(e min ) < cost(e ). Which of the following is true about e min : e min does not belong to any MST (minimum cost spanning tree) of G. e min belongs to every MST (minimum cost spanning tree) of G. e min might belong to some MSTs of G, but it s not guaranteed to belong to all MSTs of G. Problem 2(b). [5 points] Let e max be the highest cost edge, in other words: For all e E, cost(e max ) > cost(e ). Which of the following is true about e max : e max does not belong to any MST (minimum cost spanning tree) of G. e max belongs to every MST (minimum cost spanning tree) of G. e max might belong to some MSTs of G, but it s not guaranteed to belong to all MSTs of G. Problem 2(c). [5 points] Let G = (V, E), V = n, be a DAG (directed acyclic graph), and let v 1 < v 2 <... < v n be a topological sorting of V (so that v i v j E implies v i < v j ). Suppose that we create a graph G by adding a single new edge v k v l to G, for some v k > v l in the topological sorting. Is the following proposition true or false: G always contains a cycle.

Name: 3 Problem 2(d)-(g). We run DFS on a directed graph G = (V, E). Problem 2(d). [5 points] What can we conclude, if anything, about the vertex with highest postorder number (in other words, the vertex which finishes last)? Problem 2(e). [5 points] If G were a DAG (directed acyclic graph), what can we conclude, if anything, about the vertex with highest postorder number (in other words, the vertex which finishes last)? Problem 2(f). [5 points] What can we conclude, if anything, about the vertex with lowest postorder number (in other words, the vertex which finishes first)? Problem 2(g). [5 points] If G were a DAG (directed acyclic graph), what can we conclude, if anything, about the vertex with lowest postorder number (in other words, the vertex which finishes first)? Problem 2(h). [5 points] Given the following Min-Heap structure, perform Decrease-Key of vertex G to 5. Write the new Min-Heap structure.

Name: 4 Problem 3. [20 points] Let G = (V, E), V = n, be a directed graph with positive costs on its edges. Let C be a given positive number. Give an O(n 3 ) time algorithm that determines if G has a cycle of cost smaller than C. In this problem you must give the pseudocode and argue about the running time.

Name: 5 Problem 4. Let G = (V, E) be a directed graph with weights on its edges, and let s V be a specified vertex in V. Let s = v 0 v 1 v 2... v k = u be a path from s to another vertex u. Define the bottleneck of the above path as the weight of the heaviest edge along this path. Now define a min bottleneck path from s to u as a path from s to u whose bottleneck is as small as possible. In other words, we want to find a path from s to u which minimizes the maximum weight edge on the path. Problem 4(a). [10 points] Give an algorithm that finds a min bottleneck path from s to every other vertx u V, by modifying Dijkstra s algorithm. For this part, you only need to show the modifications of the pseudocode on Dijkstra s algorithm. Dijkstra(G, weight, s) 1 for each vertex v V [G] 2 do dist[v] 3 prev[v] nil 4 dist[s] 0 5 H = Create a new heap H 6 for each vertex v V [G] 7 do Insert-Heap(H, v, dist[v]) 8 while H 9 do v Extract-Min(H) 10 for all edges (v, w) E 11 do if dist[w] > dist[v] + weight(v, w) 12 then 13 dist[w] dist[v] + weight(v, w) 14 Decrease-Key(H, w, dist[w]) 15 prev[w] v

Name: 6 Problem 4(b). [10 points] What is the running time of your min-bottleneck resulting algorithm? Give your answer in terms of V and E, and explain your answer (i.e., do not say it is the same as Dijkstra s ).

Name: 7 Problem 5. [20 points] Let G = (V, E) be a connected graph with costs on its edges, and suppose that these costs are either 0 or 1. Give an O( V + E ) time algorithm to find the cost of an MST (minimum cost spanning tree) in G. You may describe your algorithm in English, or give clear pseudocode, and you must argue about the running time. You can use the algorithms presented in class as subroutines without rewriting their pseudocode, but state clearly which algorithm and its running time.

Name: 8

Name: 9

Name: 10

Name: 11