Question 5
Back to Exercise
A recursive depth-first search does not declare any collection for pending vertices. What plays that role?
- A The heap
- B The JVM call stack Correct
- C A hidden queue in the JDK
- D The garbage collector
Correct Answer: Option B
Each recursive call is a stack frame; returning from it is the "pop". An iterative DFS uses an explicit stack such as ArrayDeque.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!