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:
•
Dijkstra’s algorithm for shortest paths, starting from
S
.
•
Prim’s algorithm for the Minimum Spanning Tree (MST), starting from
S
(ignoring edge
directions).
•
Kruskal’s 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 Prim’s 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 Kruskal’s 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 Dijkstra’s algorithm,
S
has been taken off the top of
the priority queue and marked as “visited”. Which 4 vertices would be marked next in
Dijkstra’s 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