ID:151520
 
I'm currently updating my pif_DataStructures library, and adding more data structures. I currently have a tree type, and when I delete a given node on tree, the operation effectively prunes the branch from the point of the node and then deletes the resultant tree, pretty much destroying the branch. I don't believe this is the best way to go about it, and I can't really think of a general-case algorithm for doing so. My attempts at Google have failed me.

Note that any suggested algorithms would work for both an n-ary tree and a tree that can have an arbitrary number of child nodes. I'm aware how to implement a deletion in a heap and binary search tree and etc., but not how to do so in an unordered tree.
I'm currently updating my pif_DataStructures library, and adding more data structures. I currently have a tree type, and when I delete a given node on tree, the operation effectively prunes the branch from the point of the node and then deletes the resultant tree, pretty much destroying the branch. I don't believe this is the best way to go about it, and I can't really think of a general-case algorithm for doing so. My attempts at Google have failed me.

Huh? That would seem to be the correct result of deleting a node from a generic tree. If it's not a specific type of tree where would putting the orphan nodes make sense :P?
In response to Theodis
No idea. I wasn't sure if there was a better algorithm for deletion of a node in an unordered tree, but if it seems this is the best method for doing so. then I'll go with that.
In response to Popisfizzy
No idea. I wasn't sure if there was a better algorithm for deletion of a node in an unordered tree, but if it seems this is the best method for doing so. then I'll go with that.

Before trying to figure out an algorithm it helps to figure out what you want it to be doing :P! Anyway yeah for a generic tree it makes the most sense to remove it and all its children. If the user needs to preserve the nodes or place them elsewhere it should be up to them.