S
Steve Edwards
Hi,
I have a class which contains a single ptr to another instance which is
considered its parent, and an array of ptrs to its children
class Nodes{
....
Nodes *mSuper;
vector<<Nodes*> *mChildren;
}
Eventually I end up with a structure with one node at the top (with no
parents) and many leaf nodes at the bottom with no children.
I'm guessing this would be called a tree structure?... either way I
assume it's a very common structure.
Given the top node, what is the most efficient way to calculate the
final depth of the tree? (i.e. how many ptr links from the most deeply
nested leaf, to the top) I've got in a right old mess trying to keep
track of globals that note my position in the tree.
If , as I suspect, this is a common device, what terms could I search
for to look for code examples for working with these structures?
Many thanks
Steve
I have a class which contains a single ptr to another instance which is
considered its parent, and an array of ptrs to its children
class Nodes{
....
Nodes *mSuper;
vector<<Nodes*> *mChildren;
}
Eventually I end up with a structure with one node at the top (with no
parents) and many leaf nodes at the bottom with no children.
I'm guessing this would be called a tree structure?... either way I
assume it's a very common structure.
Given the top node, what is the most efficient way to calculate the
final depth of the tree? (i.e. how many ptr links from the most deeply
nested leaf, to the top) I've got in a right old mess trying to keep
track of globals that note my position in the tree.
If , as I suspect, this is a common device, what terms could I search
for to look for code examples for working with these structures?
Many thanks
Steve