• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Graph Traversals with Answers

Question 11

Is the following statement true/false? A DFS of a directed graph always produces the same number of tree edges, i.e., independent of the order in which vertices are considered for DFS. 

  • True

  • False

Question 12

If the DFS finishing time f[u] > f[v] for two vertices u and v in a directed graph G, and u and v are in the same DFS tree in the DFS forest, then u is an ancestor of v in the depth-first tree.

  • True

  • False

Question 13

Consider the DAG with Consider V = {1, 2, 3, 4, 5, 6}, shown below. Which of the following is NOT a topological ordering? 

[caption width="800"] [/caption]
  • 1 2 3 4 5 6

  • 1 3 2 4 5 6

  • 1 3 2 4 6 5

  • 3 2 4 1 6 5

Question 14

Let G be a graph with n vertices and m edges. What is the tightest upper bound on the running time on Depth First Search of G? Assume that the graph is represented using adjacency matrix.
  • O(n)
  • O(m+n)
  • O(n2)
  • O(mn)

Question 15

Consider the tree arcs of a BFS traversal from a source node W in an unweighted, connected, undirected graph. The tree T formed by the tree arcs is a data structure for computing.

  • the shortest path between every pair of vertices.

  • the shortest path from W to every vertex in the graph.

  • the shortest paths from W to only those nodes that are leaves of T.

  • the longest path in the graph

Question 16

Suppose depth first search is executed on the graph below starting at some unknown vertex. Assume that a recursive call to visit a vertex is made only after first checking that the vertex has not been visited earlier. Then the maximum possible recursion depth (including the initial call) is _________. GATECS2014Q20
  • 17
  • 18
  • 19
  • 20

Question 17

Let T be a depth first search tree in an undirected graph G. Vertices u and n are leaves of this tree T. The degrees of both u and n in G are at least 2. which one of the following statements is true?
  • There must exist a vertex w adjacent to both u and n in G
  • There must exist a vertex w whose removal disconnects u and n in G
  • There must exist a cycle in G containing u and n
  • There must exist a cycle in G containing u and all its neighbours in G.

Question 18

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?
  • {u,v} must be an edge in G, and u is a descendant of v in T
  • {u,v} must be an edge in G, and v is a descendant of u in T
  • If {u,v} is not an edge in G then u is a leaf in T
  • If {u,v} is not an edge in G then u and v must have the same parent in T

Question 19

In a depth-first traversal of a graph G with n vertices, k edges are marked as tree edges. The number of connected components in G is
  • k
  • k + 1
  • n - k - 1
  • n - k

Question 20

Consider the following directed graph. \"GATECS20167\" The number of different topological orderings of the vertices of the graph is   Note : This question was asked as Numerical Answer Type.

  • 1

  • 2

  • 4

  • 6

There are 30 questions to complete.

Last Updated :
Take a part in the ongoing discussion