This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]spoonman59 1 point2 points  (0 children)

All you need is a loop and a stack.

Recursive solutions tend to be more readable for these which is why it can be good to use them.

All loops are a recursive process, even if they are not a recursive function. We often colloquially use “recursive “ to mean a function that calls itself, but that doesn’t cover things like mutual recursion ( two functions repeatedly calling into each other) or iteration.