Algorithms | Graph Traversals | Question 2

Last Updated :
Discuss
Comments

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

Share your thoughts in the comments