|
Posted by Martyr2 on 09/19/05 22:33
I had come across a similiar exercise in a C++ class I had in college.
What you are describing is a binary tree (except in this case it has
more than just two children), where the branches show generations. I
have to tell you the methodology in C++ and then you can apply it in
PHP. We solved this through the use of a linked list with a set of
pointers and recursion. Each object points to its children and while
the pointers are not null, it calls the childs method and starts the
process all over again until it reaches the end. When it hits null, it
climbs up and down into the next child. When children are exhausted for
a given parent, it calls its parent etc back up the tree. I have found
an article which shows the ideas, problems, and a few code solutions.
http://cslibrary.stanford.edu/110/BinaryTrees.html
I hope this helps and makes sense.
Navigation:
[Reply to this message]
|