R – Delete multiple nodes from a binary search tree

binary-search-treec

I have a binary search tree created in C. The problem is I can't find a efficient way to delete all the nodes with e.g., id>5.

When I traverse the tree, if I delete a node, the recursion is getting error, because the structure is not the same.

Is there any way, instead of using a helping stack to keep the data before delete them from the tree?

Best Answer

Did you try postorder?
Delete the node after its children.

Related Topic