help deleting from a binary tree

This is a discussion on help deleting from a binary tree within the C Programming forums, part of the General Programming Boards category; I have built a binary search tree but am really stuck with the delete function. My code so far is ...

  1. #1
    Unregistered
    Guest

    Question help deleting from a binary tree

    I have built a binary search tree but am really stuck with the delete function.

    My code so far is

    BSTreeADT removeItem(itemType item, BSTreeADT t)
    {
    if (isEmptyBSTree(t))
    return t;

    if (isEmptyBSTree(leftTree(t)))
    return rightTree(t);

    else if (isEmptyBSTree(rightTree(t)))
    return leftTree(t);

    else
    /* return new tree constructed with least value in rightTree(t) as root
    current leftTree(t)
    tree constructed by removing least value from rightTree(t)

    end if

    end if
    }

    please could someone point me in the right direction?

  2. #2
    Nosepicker DrakkenKorin's Avatar
    Join Date
    Nov 2001
    Posts
    407
    This topic is currently being discussed here
    DrakkenKorin

    Get off my Intarweb!!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 11-04-2006, 11:07 AM
  2. Binary Tree, couple questions
    By scoobasean in forum C Programming
    Replies: 3
    Last Post: 03-12-2005, 09:09 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  4. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21