|
-
January 27th, 2004, 01:25 AM
#5
Here's the rough idea.
First, you can create a class/structure for each node and it should keep a list of its children node. If the list is empty, it can be used to indicate a leave node.
For the traversing part, you can start by passing the first node into recursive function. The function checks if the list is not empty and loop through each node and calling the same function. The function should only return when it reaches the leave node.
You may also like to pass another parameter, which keep track of the list of nodes you have already traverse, into the recursive function. Just before returning from the recursive function, you can print out the result.
Hope this helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|