3 ms·
It would be more helpful to display the order of traversal on the graph itself. Maybe put the step numbers, or have a trail showing the steps as they happen. T
by ben509 8y ago
It would be more helpful to display the order of traversal on the graph itself. Maybe put the step numbers, or have a trail showing the steps as they happen.
The other problem people have with recursion is seeing the problem from the point of view of the algorithm itself. That is, designing a recursive algorithm is about breaking it into a handful of specific cases. So if you could gray out everything but what is being considered, that would help someone see what the traversal is doing, and why it eventually visits all nodes.
And you could show a stack or queue to indicate the resources an algorithm needs to maintain to perform the traversals.
Finally, why do we want preorder vs. postorder? Maybe think of some things you do with these to drive home why certain traversals are preferred over others in different scenarios.