Kevin wrote:
> Hello,
>
> Any rule of thumb as how to write a tree data structure for fast
> "updating / traverse"?
>
> For example, say we have a tree like:
>
>                                           a
>                                    b    c   d    e
>                                f    g   ......
>
> Node a is parent of node b, c, d, e. And node b is the parent of node f
> and g. etc.
> Each node has a count (integer) there.
> Now, if we have a new data like "abg", then we start at the root node
> a, go down to node b, and then down to node g. And update their counts
> along the way.
> Suppose the tree will be "wide" (each node can have many children
> nodes), and not "tall" (just several levels).
>
> I use a hashtable in each node (see below) to keep the children
> informatin (hash their id to their node), but this seems not fast
> (based on my experience using other people's programs having the same
> purpose).
>
> class OneNode
> {
>   int count;
>   Hashtable hash_ChildID_To_ChildNode;
> }
>
> Any idea of how to do it more quickly?
>

This is a very reasonable way to do it.  It's likely that the only way
you'll go faster is to find a way to map IDs to nodes that's faster
than general purpose hash tables.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to