Top MCQs on Graph Data Strcuture with Answers

A Graph is a non-linear data structure consisting of vertices and edges. The vertices are sometimes also referred to as nodes and the edges are lines or arcs that connect any two nodes in the graph. More formally a Graph is composed of a set of vertices( V ) and a set of edges( E ). The graph is denoted by G(E, V).
More on Graph Data structure

Graph Data Structure Quiz

Graph Data Structure Quiz

Question 1
Which of the following is an advantage of adjacency list representation over adjacency matrix representation of a graph?
Cross
In adjacency list representation, space is saved for sparse graphs.
Cross
DFS and BSF can be done in O(V + E) time for adjacency list representation. These operations take O(V^2) time in adjacency matrix representation. Here is V and E are number of vertices and edges respectively.
Cross
Adding a vertex in adjacency list representation is easier than adjacency matrix representation.
Tick
All of the above


Question 2

The degree sequence of a simple graph is the sequence of the degrees of the nodes in the graph in decreasing order. Which of the following sequences can not be the degree sequence of any graph? 
 

I. 7, 6, 5, 4, 4, 3, 2, 1
II. 6, 6, 6, 6, 3, 3, 2, 2
III. 7, 6, 6, 4, 4, 3, 2, 2
IV. 8, 7, 7, 6, 4, 2, 1, 1 


 

Cross

I and II

Cross

III and IV

Cross

IV only

Tick

II and IV



Question 2-Explanation: 

Both II and IV cannot be the degree sequence of any graph.

Question 3

The time complexity of computing the transitive closure of a binary relation on a set of n elements is known to be:

Cross

O(n)

Cross

O(nLogn)

Cross

O(n ^ (3/2))

Tick

O(n^3)



Question 3-Explanation: 

The time complexity of computing the transitive closure of a binary relation on a set of n elements is O(n^3) using the Floyd-Warshall algorithm.

Question 4

The most efficient algorithm for finding the number of connected components in an undirected graph on n vertices and m edges has time complexity.

Cross

theta(n)

Cross

theta(m)

Tick

theta(m + n)

Cross

theta(mn)



Question 4-Explanation: 

Connected components can be found in O(m + n) using Tarjan's algorithm. Once we have connected components, we can count them.

Question 5

Consider an undirected unweighted graph G. Let a breadth-first traversal of G be done starting from a node r. Let d(r, u) and d(r, v) be the lengths of the shortest paths from r to u and v respectively, in G. lf u is visited before v during the breadth-first traversal, which of the following statements is correct?

Cross

d(r, u) < d (r, v)

Cross

d(r, u) > d(r, v)

Tick

d(r, u) <= d (r, v)

Cross

None of the above



Question 5-Explanation: 

d(r, u) and d(r, v) will be equal when u and v are at same level, otherwise d(r, u) will be less than d(r, v)

Question 6
How many undirected graphs (not necessarily connected) can be constructed out of a given set V= {V 1, V 2,…V n} of n vertices ?
Cross
n(n-l)/2
Cross
2^n
Cross
n!
Tick
2^(n(n-1)/2)


Question 6-Explanation: 
In an undirected graph, there can be maximum n(n-1)/2 edges. We can choose to have (or not have) any of the n(n-1)/2 edges. So, total number of undirected graphs with n vertices is 2^(n(n-1)/2).
Question 7

Which of the following statements is/are TRUE for an undirected graph? 

P: The number of odd-degree vertices is even 

Q: Sum of degrees of all vertices is even

Cross

P Only

Cross

Q Only

Tick

Both P and Q

Cross

Neither P nor Q



Question 7-Explanation: 

P is true for undirected graph as adding an edge always increases degree of two vertices by 1. Q is true: If we consider sum of degrees and subtract all even degrees, we get an even number because every edge increases the sum of degrees by 2. So total number of odd degree vertices must be even.

Question 8
Consider an undirected random graph of eight vertices. The probability that there is an edge between a pair of vertices is 1/2. What is the expected number of unordered cycles of length three?
Cross
1/8
Cross
1
Tick
7
Cross
8


Question 8-Explanation: 
A cycle of length 3 can be formed with 3 vertices. There can be total 8C3 ways to pick 3 vertices from 8. The probability that there is an edge between two vertices is 1/2. So expected number of unordered cycles of length 3 = (8C3)*(1/2)^3 = 7
Question 9

In which scenario would a directed acyclic graph (DAG) be most suitable?

Tick

Representing dependencies between tasks in a project schedule

Cross

Modeling a social network with friend connections

Cross

Finding the shortest path between two nodes in a weighted graph

Cross

Performing breadth-first search (BFS) on a graph



Question 9-Explanation: 

Directed acyclic graphs (DAGs) are commonly used to represent dependencies between tasks in a project schedule. DAGs ensure that the tasks are organized in a way that no cycles exist, allowing for efficient scheduling and task sequencing.

Question 10
How many undirected graphs (not necessarily connected) can be constructed out of a given set V = {v1, v2, ... vn} of n vertices?
Cross
n(n-1)/2
Cross
2n
Cross
n!
Tick
2n(n-1)/2


Question 10-Explanation: 
There are total n*(n-1)/2 possible edges. For every edge, there are to possible options, either we pick it or don\'t pick. So total number of possible graphs is 2n(n-1)/2.
There are 38 questions to complete.


  • Last Updated : 27 Sep, 2023

Share your thoughts in the comments
Similar Reads