LearnFrenzy
Sign in Take a free test

Data Structures in Java · Data Structures in Java MCQ · Question 5

How recursive depth-first search keeps its path Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links