Q. What is a key difference between BFS and DFS?
-
A.
BFS uses a stack, DFS uses a queue.
-
B.
BFS explores nodes level by level, DFS explores as far as possible along a branch.
-
C.
BFS is faster than DFS.
-
D.
DFS is always more memory efficient than BFS.
Solution
BFS explores nodes level by level, while DFS explores as far as possible along a branch before backtracking.
Correct Answer:
B
— BFS explores nodes level by level, DFS explores as far as possible along a branch.
Learn More →
Q. Which algorithm would you use to find the shortest path in an unweighted graph?
-
A.
Dijkstra's Algorithm
-
B.
Depth-First Search
-
C.
Breadth-First Search
-
D.
A* Search
Solution
Breadth-First Search (BFS) is used to find the shortest path in an unweighted graph.
Correct Answer:
C
— Breadth-First Search
Learn More →
Q. Which traversal method explores all neighbors of a node before moving to the next level?
-
A.
Depth-First Search
-
B.
Breadth-First Search
-
C.
Dijkstra's Algorithm
-
D.
A* Search
Solution
Breadth-First Search (BFS) explores all neighbors of a node before moving deeper into the graph.
Correct Answer:
B
— Breadth-First Search
Learn More →
Showing 1 to 3 of 3 (1 Pages)