a problem when deleting a node in a tree

Thank you
Last edited on
You cannot find the predecessor of the current item when you're iteration over the child items (except it's a closed circuit which is certainly not a tree)

For DeleteNode() you need to pass either the predecessor or root as a second parameter. With the root as a parameter you can find the predecessor.

But: when you delete a node how do you plan to arrange the children of that node?
I suggest to delete the node from the predecessor and recursively insert all children of the deleted node
Topic archived. No new replies allowed.