Deleting a node from a binary tree

A

A

Hi,

I'm trying to solve the 3rd and final case in deleting a node from a binary
tree. That is, deleting a node that has two subtrees. If someone out there
who knows about this problem as they have done it before or is currently
doing something similar then please give me some links with code.


Regards,
dfgf
 
V

Victor Bazarov

A said:
I'm trying to solve the 3rd and final case in deleting a node from a binary
tree. That is, deleting a node that has two subtrees. If someone out there
who knows about this problem as they have done it before or is currently
doing something similar then please give me some links with code.

What does this problem have to do with the C++ language? If you in the
future encounter a generic programming problem like this, please consider
posting to comp.programming. If you have a problem that involves some
C++ _code_, post the code. For more advice please read FAQ section 5.

Victor
 
K

Karl Heinz Buchegger

A said:
Hi,

I'm trying to solve the 3rd and final case in deleting a node from a binary
tree. That is, deleting a node that has two subtrees. If someone out there
who knows about this problem as they have done it before or is currently
doing something similar then please give me some links with code.

(I assume a BST, otherwise the whole thing is trivial :)

Where is the problem?
Every textbook on algorithms knows the solution:

search for the largest node in the left subtree ...
(basically: 1 times down left then all the way down
right until you reach the leaf)
... disconnect that node and reconnect it as new root node
 
J

Jerry Coffin

Hi,

I'm trying to solve the 3rd and final case in deleting a node from a binary
tree. That is, deleting a node that has two subtrees. If someone out there
who knows about this problem as they have done it before or is currently
doing something similar then please give me some links with code.

Find the largest node in the left sub-tree or the smallest node in the
right sub-tree, and substitute that node into the place of the node
being deleted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top