473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Deleting a node from a binary tree

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
---
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
Jul 19 '05 #1
3 6779
"A" <A@iprimus.com.au> 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
Jul 19 '05 #2


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
kb******@gascad.at
Jul 19 '05 #3
In article <3f**********@news.iprimus.com.au>, A@iprimus.com.au 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.
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: JoeAley2003 | last post by:
Hi all... I need an example of a RemoveNodeFromBTree(Data or Pointer); function or even an alghoritm will help. Will i need to rearrange the tree after this procedure?
0
by: indo3 | last post by:
Hello, I program an xml editor with xerces for the university of Braunschweig, the user dont see any xml tags, it is represented in a JTree. Now the user shall be able to insert nodes, which...
8
by: Jimmy | last post by:
Hi everyone, I am working with a binary tree, and I am having a bit of trouble visuallizing what needs to happen when I am trying to delete a node that has two children. (no child node and one...
4
by: mathon | last post by:
Hello, im currently implementing a binary search tree means, that a greater number than root will be added as right child and a less number as left child. My insert function looks currently like...
9
by: raylopez99 | last post by:
What's the best way of implementing a multi-node tree in C++? What I'm trying to do is traverse a tree of possible chess moves given an intial position (at the root of the tree). Since every...
1
by: xian83 | last post by:
I am trying all day to make some things straight but nothing helps... Me and my collegue have built a c++ tree of a class VO. I tend to refer to the structure as a tree and not a simple list...
1
by: tina chatterjee | last post by:
i have implemented binary tree insertion and deletion using my on coding. but it was not a tough job till i got confused while deleting a node having both left and right child.I am unable to...
1
by: yogi_bear_79 | last post by:
I am enrolled in distance learning class, this amounts to self taught. I have a book and that is about it. below is my assingment. The book doesn't prove useful for examples, and I haven't had...
2
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. creating a method to search a tree to find the position of node and to return its pointer value basically i...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.