I am in the process of putting the final touch to a tree structure object
model and implementation, but I am still not decided on an important point.

Considering that operations on the tree are centralized in the Tree class,
ie you write tree.AddNode(child, parent) and not node.AddChild(child), what
would be the better way to store node relationships in your opinion ?

First option:

Each node keep a pointer to its parent and store its children locally.

Second option:

The tree contains a hash table associating each node to (1) its parent and
(2) its children. (2) could be optional, but I think the convenience and
access speed more than make up for the loss in memory. Each node will then
need a pointer to the tree.


I already made an implementation for both options and have
drawn some conclusions, but I will not disclose them as to not
influence the comments.

Also, if you think centralizing operations in the Tree class is not a
good ideas for some reasons, feel free to let me know.

Thanks for your advise!

Sébastien
www.sebastienlorion.com

Reply via email to