Deleting a node from a binary tree

Discussion in 'C++' started by A, Sep 26, 2003.

  1. A

    A Guest

    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


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.518 / Virus Database: 316 - Release Date: 11/09/2003
     
    A, Sep 26, 2003
    #1
    1. Advertising

  2. "A" <> wrote...
    > 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
     
    Victor Bazarov, Sep 26, 2003
    #2
    1. Advertising

  3. A wrote:
    >
    > 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

    --
    Karl Heinz Buchegger
     
    Karl Heinz Buchegger, Sep 26, 2003
    #3
  4. A

    Jerry Coffin Guest

    In article <3f7422ea$>, says...
    > 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.

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.
     
    Jerry Coffin, Sep 26, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,495
  2. Stub

    B tree, B+ tree and B* tree

    Stub, Nov 12, 2003, in forum: C Programming
    Replies:
    3
    Views:
    10,147
  3. Tjerk Wolterink
    Replies:
    2
    Views:
    1,443
    Dimitre Novatchev
    Aug 24, 2006
  4. Peter Mueller
    Replies:
    6
    Views:
    4,586
    Stefan Ram
    Jan 13, 2008
  5. John Bankhead

    Null parent node on custom tree node after populate on demand

    John Bankhead, Dec 4, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    286
    John Bankhead
    Dec 4, 2006
Loading...

Share This Page