On 7/26/07, Sébastien Lorion <[EMAIL PROTECTED]> wrote:
> 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!
>

I'll ask the obvious questions - what is it that you're doing that
requires the tree? What kind of tree is that? What are the operations
you perform on it except adding nodes?

Cheers,
Stoyan

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to