I need to read in from an Access database a list of members. Each member was sponsored by another member. Each record contains the ID of their sponsor and their own ID. I now must be able to efficiently read in the membership roster and print it out indenting to show who was sponsored by who.
I feel the most efficient way to do this will be to build a tree and then do an inorder traversal.
My output should look something like this:
Mary Jones
Kim Smith
Rena Brown
Joan Brown
Patsy Brown
Howard Sharp
Ken Johnson
Peter Pan
Wendy
Hook
Davey Crocket
…
Order will be by ID number. Everything I find is for a Binary Tree with just a right and left son. As you see this will not work for me.
The preferred solution is Java but will appreciate anything I can get.
Bonnie
Here's what I came up with. It defines a function named
ListSponsoredMembersand calls it recursively to build the list:For a [Members] table that looks like this...
...it produces the following output: