Q. In a graph, if you want to check if there is a path between two nodes, which traversal method would be more suitable?
-
A.
BFS
-
B.
DFS
-
C.
Both are equally suitable
-
D.
Neither is suitable
Solution
Both BFS and DFS can be used to check if there is a path between two nodes, but BFS is generally preferred for finding the shortest path.
Correct Answer:
C
— Both are equally suitable
Learn More →
Q. What is a common application of DFS in graph theory?
-
A.
Finding the shortest path
-
B.
Topological sorting
-
C.
Finding the minimum spanning tree
-
D.
Finding connected components
Solution
DFS is commonly used for topological sorting, which is applicable in scheduling problems where certain tasks must be completed before others.
Correct Answer:
B
— Topological sorting
Learn More →
Q. What is the main disadvantage of using BFS?
-
A.
It can be slower than DFS
-
B.
It requires more memory
-
C.
It cannot find paths
-
D.
It is not suitable for large graphs
Solution
The main disadvantage of BFS is that it requires more memory, as it stores all nodes at the current level before moving deeper.
Correct Answer:
B
— It requires more memory
Learn More →
Showing 1 to 3 of 3 (1 Pages)