Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And depth first search is just a stack!


Yes, but it doesn't come right away. When preferring deeper nodes for a moment you have a loop-safe Depth-first traversal, and then when simplifying things in case the Graph is a Tree you get your regular stack-based Depth-first traversal, in which if you settle for the first goal you get back a tail-call optimised DFS.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: