7 ms·
Recursion / Stacks are good for DFS traversals of a graph / tree. So maybe you could do a BFS traversal using a while loop and queue of nodes to process. I thin
by mbf1 5y ago
Recursion / Stacks are good for DFS traversals of a graph / tree. So maybe you could do a BFS traversal using a while loop and queue of nodes to process. I think that approach still doesn't save you any memory.