Graph Traversal: BFS and DFS - Complexity Analysis - Higher Difficulty Problems

Download Q&A
Q. If a graph has a cycle, which traversal method can detect it?
  • A. Only BFS
  • B. Only DFS
  • C. Both BFS and DFS
  • D. Neither BFS nor DFS
Q. In DFS, what is the maximum depth of recursion for a graph with V vertices?
  • A. O(V)
  • B. O(E)
  • C. O(V + E)
  • D. O(log V)
Q. In which scenario would DFS be preferred over BFS?
  • A. Finding the shortest path
  • B. Exploring all nodes
  • C. When memory is limited
  • D. When the graph is dense
Q. What is the space complexity of BFS using an adjacency list representation?
  • A. O(V)
  • B. O(E)
  • C. O(V + E)
  • D. O(1)
Q. What is the space complexity of DFS using a recursive approach?
  • A. O(V)
  • B. O(E)
  • C. O(V + E)
  • D. O(1)
Q. What is the worst-case time complexity of DFS for a graph represented as an adjacency matrix?
  • A. O(V)
  • B. O(E)
  • C. O(V^2)
  • D. O(V + E)
Q. Which traversal method is generally faster for large graphs?
  • A. BFS
  • B. DFS
  • C. Both are equal
  • D. Depends on the graph structure
Q. Which traversal method is more memory efficient for a sparse graph?
  • A. BFS
  • B. DFS
  • C. Both are equal
  • D. Neither
Showing 1 to 8 of 8 (1 Pages)
Soulshift Feedback ×

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

Not likely Very likely