in reply to Re: Moving data in a tree
in thread Moving data in a tree
Interesting. I'd have done this a little differently. When you are traversing the tree and you are done processing a node, check to see if it only has one leaf. If so, move the single leaf to its parent node (deleting children that have no leaves). The end result would be the same (i.e., branches with single leaves would get moved to the root) but this would allow nodes that wouldn't make it all the way to the root to be propagated as high as they could be.
Of course, that's not what the OP actually requested so I could be full of...er, um...I could be wrong.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Moving data in a tree
by hoffmann (Novice) on Jul 21, 2008 at 21:10 UTC | |
by wade (Pilgrim) on Jul 21, 2008 at 21:36 UTC | |
by ysth (Canon) on Jul 22, 2008 at 06:45 UTC |