Mathematics for Data Science - 1
Graded Assignment
Week 12
1. An undirected weighted graph G is shown below. Find the set of all positive integer
values of x such that if we use Dijkstra’s algorithm, there will be a unique shortest
path from vertex a to vertex j that contains the edge (b, e).
c 8 1
h j
2
3 g
4 4
1
2
a b e 2
x
5
1 6
d f
(a) {x|x ∈ Z, 0 < x < 8}
(b) {x|x ∈ Z, 0 < x < 7}
(c) {x|x ∈ Z, 0 < x < 6}
(d) {x|x ∈ Z, 0 < x < 9}
1
2. An undirected graph G is shown below. Suppose we are trying to perform an algorithm
to find the shortest path from vertex v0 to v4 . Which of the following statements is
(are) correct?
v1 -5 v2
7 1
v0 4 v3
10
4
8 2
-9
2
v7 v4
-4 -8 1
v6 v5
5
(a) Dijkstra’s algorithm can be used to find the shortest path from v0 to v4 .
(b) Bellman-Ford algorithm can be used to find the shortest path from v0 to v4 because
there are negative weighted edges.
(c) The weight of the shortest path from v0 to v4 is 1.
(d) Bellman-Ford algorithm cannot be used to find the shortest path from v0 to v4
because there is a negative cycle in the given graph.
2
3. Which of the following statements is (are) INCORRECT?
(a) In an undirected graph G, if all edges have different positive weights, then the
minimum cost spanning tree of graph G is unique.
(b) If there is a cycle of weight 0 in a directed graph G, then we cannot find the
shortest path using Bellman-Ford algorithm.
(c) Suppose an acyclic undirected graph G with n vertices has n − 1 edges. Then the
graph is connected.
(d) In a graph G, every edge with the minimum weight will be in the minimum cost
spanning tree.
3
Use the following information for questions [4-5]:
A company has branches in each of six cities C0 , C1 , ...., C5 . The fare (in thousands of
rupees) for a direct flight from Ci to Cj is given by the (i, j)th entry in the following
matrix (∞ indicates that there is no direct flight):
0 5 ∞ ∞ 4 8
5 0 3 10 ∞ ∞
∞ 3 0 11 ∞ ∞
∞ 10 11 0 4 ∞.
4 ∞ ∞ 4 0 3
8 ∞ ∞ ∞ 3 0
4. An employee of that company wanted to travel from the city C2 to the city C5 . If
he travelled by the cheapest route possible, then the total fare (in rupees) he paid for
flight journey was
4
5. If an inspection team member wanted to inspect all the branches of the company
starting from C2 and ending at C5 , visiting each brach exactly once, then which of the
following routes should he choose in order to pay minimum fare for flight journey?
(a) C2 −→ C3 −→ C1 −→ C0 −→ C4 −→ C5
(b) C2 −→ C1 −→ C3 −→ C4 −→ C0 −→ C5
(c) C2 −→ C3 −→ C1 −→ C4 −→ C0 −→ C5
(d) Such a route is not possible.
5
Use the following information for questions [6-7]:
Seven computers {C0 , C2 , ....C6 } are linked by a network, and each link has a main-
tenance cost. The graph below shows how the computers are linked. Each node
represents a computer, each edge represents a link between a pair of computers, and
weights on the edges represent the maintenance cost (in hundreds of rupees). The goal
is to pick a subset of links such that the total maintenance cost is minimum and the
computers remain connected through the chosen links.
C0
2 1
7
C1 C2 C3
4 8
1 4 5
3 2
C4 C5 C6
6 5
6. What is the total maintenance cost (in hundreds of rupees) of the optimum subset of
links?
6
7. Find the number of different ways of choosing an optimum subset of links for the given
graph.
7
Use the following information for questions [8-9]:
Consider a weighted graph G with 7 vertices {A, B, C, D, E, F, G}, which is represented
by the following adjacency matrix.
0 6 0 0 9 0 7
6 0 0 8 0 0 0
0 0 0 0 0 1 3
0 8 0 0 2 0 0
.
9 0 0 2 0 0 0
0 0 1 0 0 0 5
7 0 3 0 0 5 0
8. Suppose we perform Prim’s algorithm on the graph G starting from vertex A to find
an MCST. Then the order in which the vertices are added is
(a) A, C, F, G, B, D, E
(b) A, B, D, E, G, C, F
(c) A, B, G, C, F, D, E
(d) A, C, F, G, E, D, B
8
9. Suppose we perform Kruskal’s algorithm on the graph G starting from vertex C to find
an MCST. Which of the following edges are not added to the minimum cost spanning
tree?
(a) (A, E)
(b) (B, D)
(c) (G, F )
(d) (A, G)