Q. What is the space complexity of DFS using recursion?
-
A.
O(V)
-
B.
O(E)
-
C.
O(V + E)
-
D.
O(1)
Solution
The space complexity of DFS using recursion is O(V) due to the call stack that can go as deep as the number of vertices in the worst case.
Correct Answer:
A
— O(V)
Learn More →
Q. Which algorithm is typically used for topological sorting?
-
A.
BFS
-
B.
DFS
-
C.
Both
-
D.
None
Solution
DFS is typically used for topological sorting in directed acyclic graphs (DAGs) because it can explore all paths and backtrack effectively.
Correct Answer:
B
— DFS
Learn More →
Q. Which traversal method is more suitable for searching deep trees?
-
A.
BFS
-
B.
DFS
-
C.
Both are equally suitable
-
D.
Neither
Solution
DFS is more suitable for searching deep trees as it goes as deep as possible down one branch before backtracking.
Correct Answer:
B
— DFS
Learn More →
Showing 1 to 3 of 3 (1 Pages)