• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Graph Traversals with Answers

Question 1

Which of the following algorithms can be used to most efficiently determine the presence of a cycle in a given graph ?

  • Depth First Search

  • Breadth First Search

  • Prim\'s Minimum Spanning Tree Algorithm

  • Kruskal\' Minimum Spanning Tree Algorithm

Question 2

Traversal of a graph is different from tree because

  • There can be a loop in graph so we must maintain a visited flag for every vertex

  • DFS of a graph uses stack, but inorder traversal of a tree is recursive

  • BFS of a graph uses queue, but a time efficient BFS of a tree is recursive.

  • All of the above

Question 3

What are the appropriate data structures for following algorithms?

1) Breadth-First Search                           
2) Depth First Search                            
3) Prim\'s Minimum Spanning Tree                 
4) Kruskal\' Minimum Spanning Tree                

    •  Stack
    •  Queue
    • Priority Queue
    • Union Find
    • Queue
    • Stack
    • Priority Queue
    • Union Find
    • Stack
    • Queue
    • Union Find
    • Priority Queue 
    • Priority Queue
    • Queue
    • Stack
    • Union Find

Question 4

The Breadth First Search algorithm has been implemented using the queue data structure. One possible order of visiting the nodes of the following graph is 
 

[caption width="800"] [/caption]
  • MNOPQR

  • NQMPOR

  • QMNPRO

  • QMNPOR

Question 5

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? (GATE CS 2000)

  • {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 6

Consider the following graph,

Among the following sequences:
(I) a b e g h f 
(II) a b f e h g
(III) a b f h g e 
(IV) a f g h b e  
Which are depth first traversals of the above graph?
  • I, II and IV only
  • I and IV only
  • II, III and IV only
  • I, III and IV only

Question 7

Which of the following condition is sufficient to detect cycle in a directed graph?

  • There is an edge from currently being visited node to an already visited node.

  • There is an edge from currently being visited node to an ancestor of currently visited node in DFS forest.

  • Every node is seen twice in DFS.

  • None of the above

Question 8

Is following statement true/false If a DFS of a directed graph contains a back edge, any other DFS of the same graph will also contain at least one back edge.

  • True

  • False

Question 9

Make is a utility that automatically builds executable programs and libraries from source code by reading files called makefiles which specify how to derive the target program. Which of the following standard graph algorithms is used by Make.

  • Strongly Connected Components

  • Topological Sorting

  • Breadth First Search

  • Dijkstra\'s Shortest Path

Question 10

Given two vertices in a graph s and t, which of the two traversals (BFS and DFS) can be used to find if there is path from s to t?

  • Only BFS

  • Only DFS

  • Both BFS and DFS

  • Neither BFS nor DFS

There are 30 questions to complete.

Last Updated :
Take a part in the ongoing discussion