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

Questions On Spanning Tree, BFS & DFS

This document contains 7 multiple choice questions about graph algorithms including Prim's algorithm, breadth first search, depth first search, and Dijkstra's algorithm. The questions cover topics like finding a minimum spanning tree, order of node visits in BFS, identifying DFS traversals, and order of finalizing shortest path distances. The document provides graphs and sequences as choices to determine the correct answers.

Uploaded by

Nakshi Shah
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)
510 views

Questions On Spanning Tree, BFS & DFS

This document contains 7 multiple choice questions about graph algorithms including Prim's algorithm, breadth first search, depth first search, and Dijkstra's algorithm. The questions cover topics like finding a minimum spanning tree, order of node visits in BFS, identifying DFS traversals, and order of finalizing shortest path distances. The document provides graphs and sequences as choices to determine the correct answers.

Uploaded by

Nakshi Shah
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/ 4

Q1.

Consider the undirected graph below:

Using Prim’s algorithm to construct a minimum spanning tree starting with


node A, which one of the following sequences of edges represents a
possible order in which the edges would be added to construct the
minimum spanning tree?
(a) (E, G), (C, F), (F, G), (A, D), (A, B), (A, C)
(b) (A, D), (A, B), (A, C), (C, F), (G, E), (F, G)
(c) (A, B), (A, D), (D, F), (F, G), (G, E), (F, C)
(d) (A, D), (A, B), (D, F), (F, C), (F, G), (G, E)

Q2. Using Prim’s Algorithm, find the cost of minimum spanning tree
(MST) of the given graph
Q3. The Breadth First Search algorithm has been implemented using the
queue data structure. One possible order of visiting the nodes of the
following graph is:

(a) MNOPQR (b) NQMPOR


(c) QMNPRO (d) QMNPOR

Q4. Consider the following graph

Among the following sequences:


i) a b e g h f
ii) a b f e h g
iii) a b f h g e
iv) a f g h b e
Which are depth first traversals of the above graph?
(a) I, II and IV only (b) I and IV only
(c) II, III and IV only (d) I, III and IV only
Q5. Suppose we run Dijkstra’s single source shortest-path algorithm on
the following edge weighted directed graph with vertex P as the
source. In what order do the nodes get included into the set of
vertices for which the shortest path distances are finalized?

(a) P, Q, R, S, T, U (b) P, Q, R, U, S, T
(c) P, Q, R, U, T, S (d) P, Q, T, R, U, S

Q6. Dijkstra’s single source shortest path algorithm when run from vertex
a in the below graph, computes the correct shortest path distance to

(a) only vertex a


(b) only vertices a, e, f, g, h
(c) only vertices a, b, c, d
(d) all the vertices
Q7. Let G be an undirected graph. Consider a depth-first traversal of G,
and let T be the resulting depth-first search tree. Let u be a vertex in
G and let v be the first new (unvisited) vertex visited after visiting u
in the traversal. Which of the following statements is always true?
(a) {u,v} must be an edge in G, and u is a descendant of v in T
(b) {u,v} must be an edge in G, and v is a descendant of u in T
(c) If {u,v} is not an edge in G then u is a leaf in T
(d) If {u,v} is not an edge in G then u and v must have the same parent in
T

Ans:
1) D
2) --
3) C
4) D
5) B
6) D
7) C

You might also like