Are there any cases when I would want to use an explicit stack data-structure in my algorithms, as opposed to doing recursion (which uses the call stack)?
Is there any benefit to doing it one way over the other? I would think using the explicit data-structure would be more performant because it doesn’t require the method calls but then again that is micro-optimization land.
One case I can think of where you could argue in favor of an explicit stack:
You might be on a system where entering and/or exiting stack frames is expensive, and your recursion depth is very deep. Imagine a depth-first in a tree.
In such a setup, if you found the requested tree node 100 levels deep, you need to destroy 100 stack frames one by one if you’re using recursion.
Using an explicit stack, you can just return from your function, and the complete stack will be released at once.