Graph Traversal: BFS and DFS - Complexity Analysis

Download Q&A
Q. In a complete binary tree, what is the time complexity of DFS?
  • A. O(log n)
  • B. O(n)
  • C. O(n log n)
  • D. O(1)
Q. In which scenario would BFS be preferred over DFS?
  • A. Finding the shortest path in an unweighted graph
  • B. Finding a path in a maze
  • C. Topological sorting
  • D. Finding connected components
Q. What is the main difference in traversal order between BFS and DFS?
  • A. BFS uses a stack, DFS uses a queue
  • B. BFS uses a queue, DFS uses a stack
  • C. BFS is depth-first, DFS is breadth-first
  • D. There is no difference
Q. What is the space complexity of BFS in a graph?
  • A. O(V)
  • B. O(E)
  • C. O(V + E)
  • D. O(1)
Q. What is the space complexity of Depth-First Search (DFS) using recursion?
  • A. O(V)
  • B. O(E)
  • C. O(V + E)
  • D. O(1)
Q. What is the worst-case time complexity of DFS in a graph?
  • A. O(V)
  • B. O(E)
  • C. O(V + E)
  • D. O(V * E)
Q. Which of the following statements is true regarding BFS?
  • A. It can be implemented using a stack
  • B. It can find the shortest path in weighted graphs
  • C. It uses a queue for traversal
  • D. It is faster than DFS in all cases
Q. Which traversal method is more memory efficient for sparse graphs?
  • A. BFS
  • B. DFS
  • C. Both are equal
  • D. Neither is efficient
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