Tree Walking

Additional example

Comments are moderated. It may take a few minutes before your comment appears.
Markdown is supported in your comments.

If you want breadth first search, replace to_crawl.extend() with to_crawl.extendleft() To dynamically switch between BFS and DFS, add a test to decide either extend() or extendleft(). I use this to walk the tree of nonogram solutions, where promising solutions are scanned depth first and improbable solutions are eventually processed breadth first.

Mail: (not shown)

Please type this: