Q. What is the primary application of DFS in graph theory?
-
A.
Finding shortest paths
-
B.
Topological sorting
-
C.
Finding minimum spanning tree
-
D.
Finding connected components
Solution
DFS is primarily used for topological sorting in directed acyclic graphs (DAGs).
Correct Answer:
B
— Topological sorting
Learn More →
Q. What is the worst-case time complexity of DFS on a graph?
-
A.
O(V + E)
-
B.
O(V^2)
-
C.
O(E)
-
D.
O(V)
Solution
The worst-case time complexity of DFS is O(V + E), as it visits every vertex and edge in the graph.
Correct Answer:
A
— O(V + E)
Learn More →
Q. Which algorithm is better for finding connected components in a graph?
-
A.
BFS
-
B.
DFS
-
C.
Both are equally good
-
D.
None of the above
Solution
Both BFS and DFS can be used to find connected components in a graph, and they are equally effective for this purpose.
Correct Answer:
C
— Both are equally good
Learn More →
Q. Which of the following is true about BFS?
-
A.
It uses a stack
-
B.
It finds the shortest path in unweighted graphs
-
C.
It is faster than DFS
-
D.
It cannot be implemented recursively
Solution
BFS finds the shortest path in unweighted graphs by exploring all neighbors at the present depth prior to moving on to nodes at the next depth level.
Correct Answer:
B
— It finds the shortest path in unweighted graphs
Learn More →
Q. Which traversal method is guaranteed to find the shortest path in a weighted graph?
-
A.
BFS
-
B.
DFS
-
C.
Dijkstra's Algorithm
-
D.
A* Search
Solution
Dijkstra's Algorithm is specifically designed to find the shortest path in weighted graphs, unlike BFS and DFS.
Correct Answer:
C
— Dijkstra's Algorithm
Learn More →
Showing 1 to 5 of 5 (1 Pages)