Q. In a graph, which traversal method uses a queue data structure?
-
A.
DFS
-
B.
BFS
-
C.
Both DFS and BFS
-
D.
Neither DFS nor BFS
Solution
BFS (Breadth-First Search) uses a queue to keep track of the next vertex to visit.
Correct Answer:
B
— BFS
Learn More →
Q. What is the primary data structure used in DFS?
-
A.
Array
-
B.
Stack
-
C.
Queue
-
D.
Linked List
Solution
DFS uses a stack (either explicitly or via recursion) to keep track of vertices.
Correct Answer:
B
— Stack
Learn More →
Q. Which of the following is a disadvantage of DFS?
-
A.
It can get stuck in deep paths.
-
B.
It requires more memory than BFS.
-
C.
It cannot be implemented recursively.
-
D.
It is slower than BFS.
Solution
DFS can get stuck in deep paths, leading to inefficient traversal in certain graphs.
Correct Answer:
A
— It can get stuck in deep paths.
Learn More →
Showing 1 to 3 of 3 (1 Pages)