PDA

View Full Version : Any ideas for optimization of tree operation?



cronodragon
27-06-2008, 01:55 PM
Hello PGDs!

I'm trying to optimize this problem: there is a custom multinode tree data structure. I have references to different nodes in the tree. Each reference has the path of a node in the tree (that could or couldn't exist, doesn't matter), and a pointer to it. This pointer works as a shortcut to the node. Now I want to delete some nodes, and I need to update the corresponding references, so those doesn't point to void objects. I can reset all of the existing references, by making the pointer nil and searching for the path again. But this is a time expensive operation. That's the situation.

I could reset just the references related to the deleted node, by backtracking the node path and comparing it to each reference, but this is indeed a much more time expensive operation, since it also takes a string comparison related to the depth of the node.

Any ideas how could I reset just the references related to the deleted node and it's children.

Thanks on advance!
-Marco