0% found this document useful (0 votes)
13 views

pdsa_ga5

Uploaded by

hathdede
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

pdsa_ga5

Uploaded by

hathdede
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Graded Assignment 5

Q1) Transitive closure(v) - If there is at least one path between vertex i to j or


i == j then v[i][j] = 1 otherwise 0. What is the transitive closure for the given

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

og the edge (i,j).


What is the weight of the minimum spanning tree for the given graph? A8) 7
_________________________________________________________________
Q9) Which of the following statement(s) is/are true about the spanning tree
of a connected graph? A9) - [x] A spanning tree is a connected acyclic
graph. - [x] A spanning tree for an n vertex graph has exactly n-1
edges. - [x] Adding an edge to a spanning tree must create a cycle. -
[x] In a spanning tree, every pair of nodes is connected by a unique path
_________________________________________________________________
Q10) Consider the following weighted adjacency list WList for a directed and

2
connected graph. What will be the path weight of the shortest path from 1 to 3?

A10) 5 ____________________________________________________________

You might also like