Data Structure MCQ - Graph
This section focuses on the "Graph" of the Data Structure. These Multiple Choice Questions (mcq) should be practiced to improve the Data Structure skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. Which of the following statements for a simple graph is correct?
A. Every path is a trail
B. Every trail is a path
C. Every trail is a path as well as every path is a trail
D. None of the mentioned
View Answer
Ans : A
Explanation: In a walk if the vertices are distinct it is called a path, whereas if the edges are distinct it is called a trail.
2. What is the maximum number of possible non zero values in an adjacency matrix of a simple graph with n vertices?
A. (n*(n-1))/2
B. (n*(n+1))/2
C. n*(n-1)
D. n*(n+1)
View Answer
Ans : C
Explanation: Out of n*n possible values for a simple graph the diagonal values will always be zero.
3. Which of the following is an advantage of adjacency list representation over adjacency matrix representation of a graph?
A. In adjacency list representation, space is saved for sparse graphs.
B. 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.
C. Adding a vertex in adjacency list representation is easier than adjacency matrix representation.
D. All of the above
View Answer
Ans : D
Explanation: No explanation.
4.A connected planar graph having 6 vertices, 7 edges contains _____________ regions.
A. 15
B. 3
C. 1
D. 11
View Answer
Ans : B
Explanation: By euler’s formula the relation between vertices(n), edges(q) and regions(r) is given by n-q+r=2.
5.On which of the following statements does the time complexity of checking if an edge exists between two particular vertices is not, depends?
A. Depends on the number of edges
B. Depends on the number of vertices
C. Is independent of both the number of edges and vertices
D. It depends on both the number of edges and vertices
View Answer
Ans : C
Explanation:To check if there is an edge between to vertices i and j, it is enough to see if the value of A[i][j] is 1 or 0, here A is the adjacency matrix.
6. 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
A. I and II
B. III and IV
C. IV only
D. II and IV
View Answer
Ans : D
Explanation: No explanation
7. What is the maximum number of edges in a bipartite graph having 10 vertices?
A. 24
B. 21
C. 25
D. 16
View Answer
Ans : C
Explanation: Let one set have n vertices another set would contain 10-n vertices.
Total number of edges would be n*(10-n), differentiating with respect to n, would yield the answer.
8. Possible number of labelled simple Directed, Pseudo and Multigarphs exist having 2 vertices?
A. 3, Infinite, 4
B. 4, 3, Infinite
C. 4, Infinite, infinite
D. 4, Infinite, Infinite
View Answer
Ans : D
Explanation: MultiGraphs and PseudoGraphs may have infinite number of edges, while 4 possible simple graphs exist.
9.The most efficient algorithm for finding the number of connected components in an undirected graph on n vertices and m edges has time complexity.
(A) \theta(n)
(B) \theta(m)
(C) \theta(m + n)
(D) \theta(mn)
A. A
B. B
C. C
D. D
View Answer
Ans : C
Explanation: Connected components can be found in O(m + n) using Tarjan's algorithm. Once we have connected components, we can count them.
10. What is time complexity to check if a string(length S1) is a substring of another string(length S2) stored in a Directed Acyclic Word Graph, given S2 is greater than S1?
A. O(S1)
B. O(S2)
C. O(S1+S2)
D. O(1)
View Answer
Ans : A
Explanation:For each check of a word of length S1, we need to follow at most S1 edges.
11. What is the number of edges present in a complete graph having n vertices?
A. (n*(n+1))/2
B. (n*(n-1))/2
C. n
D. Information given is insufficient
View Answer
Ans : B
Explanation: Number of ways in which every vertex can be connected to each other is nC2.
12. In a simple graph, the number of edges is equal to twice the sum of the degrees of the vertices.
A. True
B. False
View Answer
Ans : B
Explanation: The sum of the degrees of the vertices is equal to twice the number of edges.
13. If a simple graph G, contains n vertices and m edges, the number of edges in the Graph G'(Complement of G) is ___________
A. (n*n-n-2*m)/2
B. (n*n+n+2*m)/2
C. (n*n-n-2*m)/2
D. (n*n-n+2*m)/2
View Answer
Ans : A
Explanation: The union of G and G’ would be a complete graph so, the number of edges in G’= number of edges in the complete form of G(nC2)-edges in G(m).
14. Which of the following properties does a simple graph not hold?
A. Must be connected
B. Must be unweighted
C. Must have no loops or multiple edges
D. All of the mentioned
View Answer
Ans : A
Explanation: A simple graph maybe connected or disconnected.
15. Which of the following is true?
A. A graph may contain no edges and many vertices
B. A graph may contain many edges and no vertices
C. A graph may contain no edges and no vertices
D. None of the mentioned
View Answer
Ans : B
Explanation: A graph must contain at least one vertex.
16. For a given graph G having v vertices and e edges which is connected and has no cycles, which of the following statements is true?
A. v=e
B. v = e+1
C. v + 1 = e
D. None of the mentioned
View Answer
Ans : B
Explanation: For any connected graph with no cycles the equation holds true.
17. for which of the following combinations of the degrees of vertices would the connected graph be eulerian?
A. 1,2,3
B. 2,3,4
C. 2,4,5
D. 1,3,5
View Answer
Ans : A
Explanation: A graph is eulerian if either all of its vertices are even or if only two of its vertices are odd.
18. A graph with all vertices having equal degree is known as a __________
A. Multi Graph
B. Regular Graph
C. Simple Graph
D. Complete Graph
View Answer
Ans : B
Explanation: The given statement is the definition of regular graphs.Explanation: The given statement is the definition of regular graphs.
19. Which of the following ways can be used to represent a graph?
A. Adjacency List and Adjacency Matrix
B. Incidence Matrix
C. Adjacency List, Adjacency Matrix as well as Incidence Matrix
D. None of the mentioned
View Answer
Ans :C
Explanation: The 3 listed methods can be used, the choice depends on the ease of use.
20. The time complexity to calculate the number of edges in a graph whose information in stored in form of an adjacency matrix is ____________
A. O(V)
B. O(E2)
C. O(E)
D. O(V2)
View Answer
Ans : D
Explanation: As V entries are 0, a total of V2-V entries are to be examined.
Also Check :
Discussion