Top MCQs on Graph Data Strcuture with Answers

Last Updated :
Discuss
Comments

Question 1

A complete, undirected, weighted graph G is given on the vertex {0, 1,...., n−1} for any fixed ‘n’. Draw the minimum spanning tree of G if a) the weight of the edge (u,v) is ∣ u−v ∣ b) the weight of the edge (u,v) is u + v

    Question 2

    Let G be the directed, weighted graph shown in below figure gra We are interested in the shortest paths from A. (a) Output the sequence of vertices identified by the Dijkstra’s algorithm for single source shortest path when the algorithm is started at node A. (b) Write down sequence of vertices in the shortest path from A to E. (c) What is the cost of the shortest path from A to E?

      Question 3

      Which of the following is an advantage of adjacency list representation over adjacency matrix representation of a graph?
      • In adjacency list representation, space is saved for sparse graphs.
      • 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.
      • Adding a vertex in adjacency list representation is easier than adjacency matrix representation.
      • All of the above

      Question 4

      In the following graph, discovery time stamps and finishing time stamps of Depth First Search (DFS) are shown as x/y, where x is discovery time stamp and y is finishing time stamp. 36 (2)
      It shows which of the following depth first forest?

      • {a, b, e} {c, d, f, g, h}
      • {a, b, e} {c, d, h} {f, g}
      • {a, b, e} {f, g} {c, d} {h}
      • {a, b, c, d} {e, f, g} {h}

      Question 5

      Consider a segment tree built on an array of N elements. What is the minimum number of node updates required to rebuild the entire tree if the original array is reversed?

      • N

      • N - 1

      • 2N - 1

      • N log N

      Question 6

      Which of the following according to you is incorrect?

      • Trie is also known as prefix tree

      • Trie requires less storage space than hashing

      • Trie allows listing of all the words with same prefix

      • Tries are collision free

      Question 7

      Which of the following statements about disjoint-set forests is false?

      • Disjoint-set forests can be used to efficiently detect cycles in a graph.

      • Disjoint-set forests can handle disconnected components efficiently.

      • The union operation in disjoint-set forests can be performed in constant time.

      • Disjoint-set forests are commonly used in minimum spanning tree algorithms.

      Question 8

      In an undirected connected planar graph G, there are eight vertices and five faces. The number of edges in G is _________.

      • 10

      • 11

      • 12

      • 6

      Question 9

      Consider the following undirected graph with edge weights as shown:





      The number of minimum-weight spanning trees of the graph is ___________.

      • 3

      • 4

      • 5

      • 2

      Question 10

      The cyclomatic complexity of the flow graph of a program provides  

      • an upper bound for the number of tests that must be conducted to ensure that all statements have been executed at most once

      • a lower bound for the number of tests that must be conducted to ensure that all statements have been executed at most once

      • an upper bound for the number of tests that must be conducted to ensure that all statements have been executed at least once

      • a lower bound for the number of tests that must be conducted to ensure that all statements have been executed at least once

      There are 38 questions to complete.

      Take a part in the ongoing discussion