pdsa_ga5
pdsa_ga5
graph?
A1) | 1 | 1 | 1 | 1 | |—|—|—|—| | 1 | 1 | 1 | 1 | | 1 | 1 | 1 | 1 | | 0 | 0 | 0 | 1 |
_________________________________________________________________
Q2) How can we use the Floyd-Warshall algorithm for all-pairs shortest paths to
detect whether a graph has a negative cycle? A2) Check if any shortest path en-
try A[i][i] is negative. ____________________________________________________
Q3) Suppose we have a weighted undirected graph with a negative weight
cycle. Which of the following is correct? A3) Both Kruskal’s algorithm and
Prim’s algorithm can be used to compute the minimum-cost spanning tree.
_________________________________________________________________
Q4) We can use Breadth First Search (BFS) instead of Dijkstra’s algo-
rithm to find out the shortest path from the given source node to every
other node only ______. A4) When all the edge weights are equal.
_________________________________________________________________
Q5) Which of the following statement is/are true? A5) - [x] Dijkstra’s
algorithm doesn’t work for graphs with negative weights - [x] Floyd
Warshall algorithm can detect negative weight cycle. - [x] Floyd War-
shall algorithm works with negative weights but without negative cycle.
_________________________________________________________________
Q6) Suppose we run Prim’s algorithm and Kruskal’s algorithm on a graph G
and these two algorithms produce minimum-cost spanning trees TP and TK,
respectively. > (I) TP may be different from TK if some pair of edges in G
have the same weight. > (II) TP is always the same as TK if all edges in G
have distinct weights. Which of the following is true? A6) Both (I) and (II)
are correct.
1
Q7) Consider the graph shown below.
Which one of the following can be the sequence of edges added, in
that order, to create a minimum spanning tree using Kruskal’s algo-
rithm? A7) - [x] (a,b) (d,f) (b,f) (d,c) (d,e) - [x] (a,b) (d,f) (d,c) (b,f)
(d,e) - [x] (d,f) (a,b) (d,c) (b,f) (d,e) - [x] (d,f) (a,b) (b,f) (d,c) (d,e)
_________________________________________________________________
Q8) Consider the given weighted adjacency matrix w for a complete undirected
graph with vertex set {0, 1, 2, 3, 4} . Where w[i][j], i � j in the matrix is the weight
2
connected graph. What will be the path weight of the shortest path from 1 to 3?
A10) 5 ____________________________________________________________