

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Problem 1 [2 × 7 = 14 points]
A
B
C
D
(^1 ) 3
4 5
simultaneously.
Problem 2 [6 points]
Kruskal’s algorithm: CD, BD. [1.5 pts]
Dijkstra’s algorithm from A: AC, BD. [1.5 pts]
Prim’s algorithm: BD, CD. [1.5 pts]
Bellman-Ford algorithm: Does not make sense. Bellman-Ford has no specified order in which it updates edges. Hence, any two edges other than AB might be processed. [1.5 pts]
Problem 3 [15 points] There are various ways of solving this problem. One solution is to construct a new graph which is identical to the given graph except that weights are on the edges instead of the vertices. We set the weight of the edge (u, v) as w(v), which is the weight of the the vertex v in the original graph. Since the hint suggests using Dijkstra’s algorithm, we can assume the weights to be positive and run Dijkstra on the new graph. [10 pts]
We claim that the shortest path in the new graph is also the shortest path in the original graph. Let s, u 1 ,... , uk, t be any s − t path in the original graph. The weight of the path is the sum of weights of all the vertices on it and is equal to w(s)+w(u 1 )+.. .+w(uk)+w(t). The weight of the same path in the new graph is w(s, u 1 ) + w(u 1 , u 2 ) +... + w(uk− 1 , uk) + w(uk, t), which is equal to w(u 1 ) + w(u 2 ) +... + w(uk) + w(t). Thus, the weights of all the paths in the old and new graphs only differ by w(s). Hence, the shortest paths in the two graphs will be the same. 3 pts
The time taken in creating the new graph is O(|V | + |E|). Since, we then run Dijkstra on the new graph, and the number of vertices and edges in the new graph is the same, the total running time is O((|V |+|E|) log |V |), using a binary heap implementation. [2 pts]
Problem 4 [15 points]