This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Directed Graph”.

1. Dijkstra’s Algorithm will work for both negative and positive weights?

a) True

b) False

View Answer

Explanation: Dijkstra’s Algorithm assumes all weights to be non-negative.

2. A graph having an edge from each vertex to every other vertex is called a ___________

a) Tightly Connected

b) Strongly Connected

c) Weakly Connected

d) Loosely Connected

View Answer

Explanation: This is a part of the nomenclature followed in Graph Theory.

3. What is the number of unlabeled simple directed graph that can be made with 1 or 2 vertices?

a) 2

b) 4

c) 5

d) 9

View Answer

4. Floyd Warshall Algorithm used to solve the shortest path problem has a time complexity of __________

a) O(V*V)

b) O(V*V*V)

c) O(E*V)

d) O(E*E)

View Answer

Explanation: The Algorithm uses Dynamic Programming and checks for every possible path.

5. All Graphs have unique representation on paper.

a) True

b) False

View Answer

Explanation: Same Graph may be drawn in different ways on paper.

6. Assuming value of every weight to be greater than 10, in which of the following cases the shortest path of a directed weighted graph from 2 vertices u and v will never change?

a) add all values by 10

b) subtract 10 from all the values

c) multiply all values by 10

d) in both the cases of multiplying and adding by 10

View Answer

Explanation: In case of addition or subtraction the shortest path may change because the number of edges between different paths may be different, while in case of multiplication path wont change.

7. What is the maximum possible number of edges in a directed graph with no self loops having 8 vertices?

a) 28

b) 64

c) 256

d) 56

View Answer

Explanation: If a graph has V vertices than every vertex can be connected to a possible of V-1 vertices.

8. What would be the DFS traversal of the given Graph?

a) ABCED

b) AEDCB

c) EDCBA

d) ADECB

View Answer

Explanation: In this case two answers are possible including ADEBC.

9. What would be the value of the distance matrix, after the execution of the given code?

#include <bits/stdc++.h> #define INF 1000000 int graph[V][V] = { {0, 7, INF, 4}, {INF, 0, 13, INF}, {INF, INF, 0, 12}, {INF, INF, INF, 0} }; int distance[V][V], i, j, k; for (i = 0; i < V; i++) for (j = 0; j < V; j++) distance[i][j] = graph[i][j]; for (k = 0; k < V; k++) for (i = 0; i < V; i++) for (j = 0; j < V; j++) { if (distance[i][k] + distance[k][j] < distance[i][j]) distance[i][j] = distance[i][k] + distance[k][j]; return 0; }

a)

{ {0, 7, INF, 4}, {INF, 0, 13, INF}, {INF, INF, 0, 12}, {INF, INF, INF, 0} };

b)

{ {0, 7, 20, 24}, {INF, 0, 13, 25}, {INF, INF, 0, 12}, {INF, INF, INF, 0} };

c)

{ {0, INF, 20, 24}, {INF, INF, 13, 25}, {INF, INF, 0, 12}, {INF, INF, INF, 0} {INF, 0, 13, 25}, {INF, INF, 0, 12}, {24, INF, INF, 0} };

d) None of the mentioned

View Answer

Explanation: The program computes the shortest sub distances.

10. What is the maximum number of edges present in a simple directed graph with 7 vertices if there exists no cycles in the graph?

a) 21

b) 7

c) 6

d) 49

View Answer

Explanation: If the no cycles exists then the difference between the number of vertices and edges is 1.

**Sanfoundry Global Education & Learning Series – Data Structure.**

To practice all areas of Data Structure, __here is complete set of 1000+ Multiple Choice Questions and Answers__.

**Related Posts:**

- Apply for Computer Science Internship
- Practice Computer Science MCQs
- Practice Programming MCQs
- Check Programming Books
- Check Data Structure Books