|
General Details
|
|
Scheme
|
|
Posted 97 Days Ago
|
|
201 Views
|
|
Received 0 Ratings
|
|
Depth-first and Breadth-first Tree Traversal
Description
Below are two types of tree traversal, depth-first and breadth-first. Note that I named the breadth-first algorithm dragon-search, because it reminds me of a dragons breath. :P (I have weird ways of remembering things.)
Anyway, please leave your comments on how I can improve this code. Thanks in advance.
Source Code
Comments
| Please login to post comments. |
|
|
Thanks. I'll experiment with that. I think that I'm getting the hang of Scheme. I just need to practice a lot more. At least the functional paradigm isn't a mind bending mystery anymore :).
|
|
|
Hi,
this looks very good. Maybe you want to think about a way to generalize
the procedures. So that the action that is performed on each node can be user supplied and maybe you even want to try to encapsulate the search-strategy into another procedure.
So that you get a generalized search algorithm that works on trees.
Sth like this maybe: (search breadth-first display) or (search depth-first display)
and later (search best-first display) or even (search (best-first A*) display) ;)
Keep up the good work
|
More "Scheme" Source Codes By This Author
Recently Posted "Scheme" Source Codes
Recently Rated "Scheme" Source Codes
|