about delete in BST
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: about delete in BST

  1. #1
    Join Date
    Jan 2013

    about delete in BST

    I feel confused about the delete in binary search tree.
    The following is the code:
    void delete(struct bst_node** node) {
        struct bst_node* old_node = *node;
        if ((*node)->left == NULL) {
            *node = (*node)->right;
        } else if ((*node)->right == NULL) {
            *node = (*node)->left;
        } else {
            delete node with two children
    This problem is from the current node and its parents. In the above codes, obviously,
    I cannot image how the parent node connect to the current node's right child, if (*node)->left == NULL; In theoretically, to find out the parent node, I should write following:
    struct bst_node* p;
    p=current_node; current_node=current->right;
    And then node p is the parent code of current. However, this algorithm not show in the function void delete(struct bst_node** node); why, and how to explain that.
    Thanks a lot.

  2. #2
    Join Date
    Feb 2011
    United States

    Re: about delete in BST

    This question is better suited to the C++ subforum.

    [ Thread moved, retaining a redirect in Algos & Data Structures ]
    Best Regards,

    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a Codeguru.com survey!

HTML5 Development Center