Computer Science 170 - Fall 1999 - Demmel - Midterm 1

Computer Science 170 - Fall 1999 - Demmel - Midterm 1 - CS...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 170, Midterm 1, Fall 1999 CS 170, Fall 1999 Midterm 1 1. (15 points) We are running one of these three algorithms on the graph below, where the algorithm has already "processed" the bold-face edges. (Ignore the directions on the edges for Prim's and Kruskal's algorithms.) Prim's for the minimum spanning tree, starting from S. Kruskal's for the minimum spanning tree. Dijkstra's for shortest path from S. Which two edges would be added next in Prim's algorithm? Be sure to indicate the order in which they are added. Answer: First (A,B) is added and then (C,F). Which two edges would be added next in Kruskal's algorithm? Be sure to indicate the order in which they are added. Answer: First (F,G) is added and then (A,B). At this point in the running of Dijkstra's algorithm, S has been taken off the top of the heap and marked. Which four vertices would be marked next in Dijkstra's algorithm, i.e. deleted from the top of the heap? Be sure to indicate the order in which they are deleted. Which final edges would Dijkstra's algorithm choose as part of the shortest path to these vertices (i.e. which edge connects to this vertex as part of the shortest path from S)? Answer: (1) C is marked, with edge (S,C). (2) A is marked, with edge (S,A). (3) D is marked with edge (S,D). (4) F is marked with edge (C, F). 2. (25 points) Let G = (V, E) be a directed graph where every edge E has weight w(E), which may be positive, negative, or zero. The benefit of a path consisting of edges E1,E2,. ..Ek is defined as min( w(Ei) for 1<=i<=k ). Give an algorithm which computes the maximum benefit path from a given vertex s to another vertex f. file:///C|/Documents%20and%20Settings/Jason%20Raft. ..-%20Fall%201999%20-%20Demmel%20-%20Midterm%201.htm (1 of 4)1/27/2007 5:32:58 PM
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 170, Midterm 1, Fall 1999 For example, if there are two paths from s to f, where Path 1 has edge weights -1, -2, -3 and Path 2 has edges weights -4, 10, 20, then Path 1 has benefit -3 and Path 2 has benefit -4, so Path 1 has the
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Computer Science 170 - Fall 1999 - Demmel - Midterm 1 - CS...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online