Graph Traversal: BFS and DFS - Competitive Exam Level

Download Q&A
Q. In which order does BFS visit nodes in a graph?
  • A. Pre-order
  • B. In-order
  • C. Post-order
  • D. Level-order
Q. What happens if you apply DFS on a graph with cycles without tracking visited nodes?
  • A. It will terminate successfully.
  • B. It will enter an infinite loop.
  • C. It will throw an error.
  • D. It will only visit some nodes.
Q. Which of the following scenarios is BFS preferred over DFS?
  • A. Finding the shortest path in an unweighted graph
  • B. Exploring all possible paths
  • C. Finding a cycle in a graph
  • D. Topological sorting
Q. Which traversal method uses a stack to explore nodes?
  • A. BFS
  • B. DFS
  • C. Dijkstra's Algorithm
  • D. Prim's Algorithm
Showing 1 to 4 of 4 (1 Pages)
Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely