Skip to content
Related Articles

Related Articles

Improve Article
Algorithms | Graph Traversals | Question 2
  • Difficulty Level : Easy
  • Last Updated : 07 Feb, 2013

Traversal of a graph is different from tree because
(A) There can be a loop in graph so we must maintain a visited flag for every vertex
(B) DFS of a graph uses stack, but inorrder traversal of a tree is recursive
(C) BFS of a graph uses queue, but a time efficient BFS of a tree is recursive.
(D) All of the above


Answer: (A)

Explanation: See https://www.geeksforgeeks.org/depth-first-traversal-for-a-graph/

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :