please gimme the logic to merge two binary search trees?I mean which
node has to be the root node of the new binary tree??
Thanks in advance 8 7795
sudharsan wrote: please gimme the logic to merge two binary search trees?I mean which node has to be the root node of the new binary tree?? Thanks in advance
Thanks for monitoring this newsgroup and being aware of what is and
is not topical for it. In the same spirit of co-operation, I offer
the following accurate method:
Install all items in a new tree, using only the left pointer, and
setting all the new right pointers to NULL. Extract the items from
the original trees with an inorder treewalk. When done, sort the
resultant list formed with the left pointers with mergesort. The
result will be a binary search tree.
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
CBFalconer wrote: sudharsan wrote: please gimme the logic to merge two binary search trees?I mean which node has to be the root node of the new binary tree?? Thanks in advance
Thanks for monitoring this newsgroup and being aware of what is and is not topical for it. In the same spirit of co-operation, I offer the following accurate method:
Install all items in a new tree, using only the left pointer, and setting all the new right pointers to NULL. Extract the items from the original trees with an inorder treewalk. When done, sort the resultant list formed with the left pointers with mergesort. The result will be a binary search tree.
--
thanks cbfalconer,
but i cudnot understand "Extract the items from
the original trees with an inorder treewalk" original tree???which one
.....of the two sorted binary tree??
sudharsan wrote: CBFalconer wrote: sudharsan wrote: please gimme the logic to merge two binary search trees?I mean which node has to be the root node of the new binary tree?? Thanks in advance
Thanks for monitoring this newsgroup and being aware of what is and is not topical for it. In the same spirit of co-operation, I offer the following accurate method:
Install all items in a new tree, using only the left pointer, and setting all the new right pointers to NULL. Extract the items from the original trees with an inorder treewalk. When done, sort the resultant list formed with the left pointers with mergesort. The result will be a binary search tree.
-- thanks cbfalconer, but i cudnot understand "Extract the items from the original trees with an inorder treewalk" original tree???which one ....of the two sorted binary tree??
You didn't get it did you? Let me spell it out:
Your question is off-topic here. Please take it to a better group. Our
neighbours in comp.programming (down the hall, second door on the
right) may be able to help. When you next have a question that involves
C programming language, feel free to call again.
--
BR, Vladimir
"Vladimir S. Oka" <no****@btopenworld.com> writes:
[...] Your question is off-topic here. Please take it to a better group. Our neighbours in comp.programming (down the hall, second door on the right) may be able to help. When you next have a question that involves C programming language, feel free to call again.
I thought comp.lang.c++ was the second door on the right. Or did you
go down the hall in the opposite direction?
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
On 2006-02-27, Keith Thompson <ks***@mib.org> wrote: "Vladimir S. Oka" <no****@btopenworld.com> writes: [...] Your question is off-topic here. Please take it to a better group. Our neighbours in comp.programming (down the hall, second door on the right) may be able to help. When you next have a question that involves C programming language, feel free to call again.
I thought comp.lang.c++ was the second door on the right. Or did you go down the hall in the opposite direction?
Wouldn't you then say "up the hall"?
Clearly, the second door on the right leads to a dead-end mini-hallway
with two doors in it leading to the rooms in question.
Jordan Abel <ra*******@gmail.com> writes: On 2006-02-27, Keith Thompson <ks***@mib.org> wrote: "Vladimir S. Oka" <no****@btopenworld.com> writes: [...] Your question is off-topic here. Please take it to a better group. Our neighbours in comp.programming (down the hall, second door on the right) may be able to help. When you next have a question that involves C programming language, feel free to call again.
I thought comp.lang.c++ was the second door on the right. Or did you go down the hall in the opposite direction?
Wouldn't you then say "up the hall"?
Obviously we're at the high point of the hall, so it's "down" in both
directions.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
sudharsan wrote: CBFalconer wrote: sudharsan wrote: please gimme the logic to merge two binary search trees?I mean which node has to be the root node of the new binary tree?? Thanks in advance
Thanks for monitoring this newsgroup and being aware of what is and is not topical for it. In the same spirit of co-operation, I offer the following accurate method:
Install all items in a new tree, using only the left pointer, and setting all the new right pointers to NULL. Extract the items from the original trees with an inorder treewalk. When done, sort the resultant list formed with the left pointers with mergesort. The result will be a binary search tree.
thanks cbfalconer, but i cudnot understand "Extract the items from the original trees with an inorder treewalk" original tree??? which one....of the two sorted binary tree??
The method will work, but will be degenerate. The point is that
the question has nothing to do with the subject of this newsgroup.
If you don't understand you need to do some studying of elementary
algorithms, which again is not topical here. I suggest getting and
reading Sedgwicks "Algorithms" or "Algorithms in C".
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
Keith Thompson wrote: Jordan Abel <ra*******@gmail.com> writes: On 2006-02-27, Keith Thompson <ks***@mib.org> wrote: "Vladimir S. Oka" <no****@btopenworld.com> writes: [...] Your question is off-topic here. Please take it to a better group. Our neighbours in comp.programming (down the hall, second door on the right) may be able to help. When you next have a question that involves C programming language, feel free to call again.
I thought comp.lang.c++ was the second door on the right. Or did you go down the hall in the opposite direction?
Wouldn't you then say "up the hall"?
Obviously we're at the high point of the hall, so it's "down" in both directions.
You can't go up. Maybe you should drop something, or turn off the
lamp to conserve batteries.
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: abhrajit |
last post by:
I'm looking for a C/C++/Java library to create a balanced binary tree
data structure given a set of leaf nodes as input. A leaf node should
never become an interior node.
So if I wish to create...
|
by: Rasmus |
last post by:
Hi.
As partly novice in python I would like a piece of advise of how to
implement (binary) trees the best way?
Thanks in advance,
Rasmus
PS: Due to heavy spam reception (20.000+/week), I...
|
by: JC |
last post by:
Hi,
I'm looking for some help on Binary trees, in particular levels, heights
etc.
I need to find the levels of a tree, I also need to determine the minimum,
maximum and average leaf levels.
...
|
by: Jerry Khoo |
last post by:
hello, everybody, i am kinda new here, nice to meet u all. Now, i am
> cs students and are now facing difficult problems in understanding
> what a binary tree is, how it works, and the algorithm...
|
by: [diegueus9] Diego Andrés Sanabria |
last post by:
Hello!!!
I want know if python have binary trees and more?
|
by: Foodbank |
last post by:
Hi all,
I'm trying to do a binary search and collect some stats from a text
file in order to compare the processing times of this program (binary
searching) versus an old program using linked...
|
by: free2cric |
last post by:
Hi,
I have a single link list which is sorted.
structure of which is like
typedef struct mylist
{
int num;
struct mylist *next;
|
by: pyguy |
last post by:
Hi all,
I am running into a conceptual glitch in implementing a simple binary tree class. My insertion and printing (sorting) seems to be ok, but when I search the tree, my find method isn't doing...
|
by: Vinodh |
last post by:
Started reading about Binary Trees and got the following questions in
mind. Please help.
Definition of a Binary Tree from "Data Structures using C and C++ by
Tanenbaum" goes like this,
"A...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
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...
|
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,...
| |