I know DFS usually can be implemented using recursion function in which system stack is used.
And I know there is Non-recursive Depth-First Search (DFS) Using a Stack.
I wonder every recursion can be called as DFS, if not, is there any example?
I know DFS usually can be implemented using recursion function in which system stack is used.
And I know there is Non-recursive Depth-First Search (DFS) Using a Stack.
I wonder every recursion can be called as DFS, if not, is there any example?
2 + 3recursively as a graph and yes, it's a DFS when implemented that way because you have2as a vertex and then edges for+1,+2,+3, etc. So,2 + 3usingsum(x, y) => y != 0 ? sum(x + 1, y - 1) : x(naive implementation) will traverse a+1edge three times. I'm still not totally convinced that every recursion is a search, though. I'll need to think about this more, perhaps.