Midterm2_Answers 2010 - CS 170 Second Midterm ANSWERS 7...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 170 Second Midterm ANSWERS 7 April 2010 NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt): Name of Neighbor to your right (1 pt): Instructions : This is a closed book, closed calculator, closed computer, closed network, open brain exam, but you are permited a 1 page, double-sided set of notes, large enough to read without a magnifying glass. You get one point each for filling in the 5 lines at the top of this page. Each other question is worth 20 points. No points will be subtracted for wrong answers so its in your best interest to guess all you want. Write all your answers on this exam. If you need scratch paper, ask for it, write your name on each sheet, and attach it when you turn it in (we have a stapler). 1 2 3 Total 1 Question 1 (20 points). We are running the following four algorithms on the graph below, where the algorithms have already processed the three bold-face edges: Dijkstras algorithm for shortest paths, starting from S . Prims algorithm for the Minimum Spanning Tree (MST), starting from S (ignoring edge directions). Kruskals algorithm for the Minimum Spanning Tree (MST) (ignoring edge directions). Breadth-First-Search (BFS) starting from S (ignoring both edge directions and edge weights, but visiting neighboring vertices in lexicographic order). (a) Which 3 edges would be added next to the MST in Prims algorithm? Be sure to indicate the order in which they are added. Answer: First (A,B), then (A,E), then (E,H). (b) Which 3 edges would be added next to the MST in Kruskals algorithm? Be sure to indicate the order in which they are added. Answer: First (G,H), then (A,B), then (E,H). (c) Which 3 edges would be added next to the BFS-tree by BFS? Be sure to indicate the order in which they are added. Answer: First (A,B), then (A,E), then (C,F). (d) At this point in the running of Dijkstras algorithm, S has been taken off the top of the priority queue and marked as visited. Which 4 vertices would be marked next in Dijkstras algorithm, i.e. deleted from the priority queue and marked? What are the shortest paths, and their lengths, to these 4 vertices? Answer: First D (shortest path S-D, length 1), then C (shortest path S-C, length 2), then A (shortest path S-A, length 3), then B (shortest path S-A-B, length 3+5=8). 2 Question 1 (20 points). We are running the following four algorithms on the graph below, where the algorithms have already processed the three bold-face edges: Dijkstras algorithm for shortest paths, starting from S . Prims algorithm for the Minimum Spanning Tree (MST), starting from S (ignoring edge directions). Kruskals algorithm for the Minimum Spanning Tree (MST) (ignoring edge directions)....
View Full Document

This note was uploaded on 04/30/2010 for the course CS 170 taught by Professor Henzinger during the Spring '02 term at University of California, Berkeley.

Page1 / 15

Midterm2_Answers 2010 - CS 170 Second Midterm ANSWERS 7...

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

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