Re:Dijkstra was right – recursion should not be difficult
by yen223 on Monday August 07, 2017 @10:06PM
(#14953091)
This neatly explains why recursive depth-first searches are far easier to implement than recursive breadth-first searches. With BFS you'll need to explicitly pass in a queue to track unvisited nodes, whereas with DFS you already get a stack for free!
[ Parent
| on HN ]
Re:Dijkstra was right – recursion should not be difficult
by neukoelln on Tuesday August 08, 2017 @02:16AM
(#14954934)
And you will also get a stack overflow for free.
Re:Dijkstra was right – recursion should not be difficult
by greghendershott on Tuesday August 08, 2017 @11:24AM
(#14958773)
In some languages the "stack" may grow until all memory is exhausted.
(Some of those languages also guarantee tail call elimination.)