Q. What is the space complexity of DFS in the worst case?
A.
O(V)
B.
O(E)
C.
O(V + E)
D.
O(V^2)
Show solution
Solution
The space complexity of DFS in the worst case is O(V) due to the stack used for recursion or explicit stack storage.
Correct Answer:
A
— O(V)
Learn More →
Q. What is the worst-case time complexity of DFS?
A.
O(V)
B.
O(E)
C.
O(V + E)
D.
O(V^2)
Show solution
Solution
The worst-case time complexity of DFS is O(V + E), as it visits each vertex and edge once.
Correct Answer:
C
— O(V + E)
Learn More →
Q. Which algorithm is more memory efficient for large graphs?
A.
BFS
B.
DFS
C.
Both are equally efficient
D.
Neither is efficient
Show solution
Solution
DFS is generally more memory efficient for large graphs because it uses less memory than BFS, which stores all nodes at the current level.
Correct Answer:
B
— DFS
Learn More →
Q. Which of the following is NOT an application of DFS?
A.
Topological sorting
B.
Finding strongly connected components
C.
Finding the shortest path
D.
Solving puzzles like mazes
Show solution
Solution
Finding the shortest path is typically not an application of DFS, as it does not guarantee the shortest path in unweighted graphs.
Correct Answer:
C
— Finding the shortest path
Learn More →
Q. Which traversal method is typically used for searching in a tree structure?
A.
BFS
B.
DFS
C.
Both BFS and DFS
D.
None of the above
Show solution
Solution
Both BFS and DFS can be used for searching in a tree structure, depending on the specific requirements of the search (e.g., shortest path vs. exhaustive search).
Correct Answer:
C
— Both BFS and DFS
Learn More →
Showing 1 to 5 of 5 (1 Pages)