473,769 Members | 5,374 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Empty binary trees

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 binary tree is a finite set of elements that is either empty or is
partitioned into three disjoint subsets. The first subset contains a
single element called the 'Root' of the tree. The other two subsets
are themselves binary trees, called the 'Left' and 'Right' subtrees of
the original tree."

My Questions:
1) Why they talk about a binary tree that is totally empty? I mean a
binary tree with Zero elements?

2) A binary tree is partioned into three disjoint subsets. That means
all the elements in a binary tree should be unique? Duplicate elements
are allowed within a subtree? Any significance of this?

Thanks,
Vinodh
Jun 27 '08 #1
7 3870
Vinodh wrote:
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 binary tree is a finite set of elements that is either empty or is
partitioned into three disjoint subsets. The first subset contains a
single element called the 'Root' of the tree. The other two subsets
are themselves binary trees, called the 'Left' and 'Right' subtrees of
the original tree."

My Questions:
1) Why they talk about a binary tree that is totally empty? I mean a
binary tree with Zero elements?
It's needed in the recursive definition. If you do not allow subtrees to be
empty, then your trees cannot have leaves and will be infinite.

2) A binary tree is partioned into three disjoint subsets. That means
all the elements in a binary tree should be unique?
Yes.
Duplicate elements are allowed within a subtree?
No.
Any significance of this?
Yes: trees do not have cycles.

BTW: your question is basically unrelated to C++ and would be better suited
for comp.programmin g.

Best

Kai-Uwe Bux
Jun 27 '08 #2
Kai-Uwe Bux wrote:
>2) A binary tree is partioned into three disjoint subsets. That means
all the elements in a binary tree should be unique?

Yes.
>Duplicate elements are allowed within a subtree?

No.
That would be incorrect. You are confusing binary trees with binary
search trees.

A binary tree doesn't impose any limitations whatsoever on the
contents of the nodes. It only defines the structure of the tree (each
node can have one parent node and two subtrees).

What you are thinking about is a binary search tree, which has the
additional limitation that all the nodes in the left subtree must be
smaller than the node itself, and the ones on the right subtree larger.
Jun 27 '08 #3
Juha Nieminen wrote:
Kai-Uwe Bux wrote:
>>2) A binary tree is partioned into three disjoint subsets. That means
all the elements in a binary tree should be unique?

Yes.
>>Duplicate elements are allowed within a subtree?

No.

That would be incorrect. You are confusing binary trees with binary
search trees.
I don't think that I am confusing anything here.

A binary tree doesn't impose any limitations whatsoever on the
contents of the nodes.
We have to distinguish the dublication of labels from the dublication of
nodes. In a tree, subtrees will not share nodes. However, different nodes
might share labels.

The definition that the OP refers to is clearly not talking about labels but
about nodes.

It only defines the structure of the tree (each
node can have one parent node and two subtrees).
And those subtrees do not share nodes.

What you are thinking about is a binary search tree,
which has the
additional limitation that all the nodes in the left subtree must be
smaller than the node itself, and the ones on the right subtree larger.
You are blurring the distinction of nodes and labels. That is not a good
idea when talking about trees. The comparison applies to labels. The
requirement that nodes be distinct is just a consequence of the absence of
cycles in trees.
Best

Kai-Uwe Bux
Jun 27 '08 #4
On Jun 3, 7:50*pm, Kai-Uwe Bux <jkherci...@gmx .netwrote:
Juha Nieminen wrote:
Kai-Uwe Bux wrote:
>2) A binary tree is partioned into three disjoint subsets. That means
all the elements in a binary tree should be unique?
Yes.
>Duplicate elements are allowed within a subtree?
No.
* That would be incorrect. You are confusing binary trees with binary
search trees.

I don't think that I am confusing anything here.
* A binary tree doesn't impose any limitations whatsoever on the
contents of the nodes.

We have to distinguish the dublication of labels from the dublication of
nodes. In a tree, subtrees will not share nodes. However, different nodes
might share labels.

The definition that the OP refers to is clearly not talking about labels but
about nodes.
It only defines the structure of the tree (each
node can have one parent node and two subtrees).

And those subtrees do not share nodes.
Right.I was talking about nodes only. And I was not asking about
"Binary Search Tree" which seems to be a specialization of a Binary
Tree. The statement that subtrees do not share nodes in a binary tree
is in synch with the definition of "the subtrees are disjoint". Thanks
for validating my understanding.
* What you are thinking about is a binary search tree,
*which has the
additional limitation that all the nodes in the left subtree must be
smaller than the node itself, and the ones on the right subtree larger.

You are blurring the distinction of nodes and labels. That is not a good
idea when talking about trees. The comparison applies to labels. The
requirement that nodes be distinct is just a consequence of the absence of
cycles in trees.
>Duplicate elements are allowed within a subtree?
No.
Right.
Recursively if we check I find that, since root and subtrees can not
have anything common, between root, left and right nothing is going to
be common in a binary tree. Hence now I am able to understand every
node value in a binary tree is Unique. Thanks

Thouh I don't know the significance of this Uniqueness.:(
Best

Kai-Uwe Bux
Jun 27 '08 #5
On Jun 3, 10:18*pm, Vinodh <pvinodhku...@g mail.comwrote:
On Jun 3, 7:50*pm, Kai-Uwe Bux <jkherci...@gmx .netwrote:


Juha Nieminen wrote:
Kai-Uwe Bux wrote:
>>2) A binary tree is partioned into three disjoint subsets. That means
>>all the elements in a binary tree should be unique?
>Yes.
>>Duplicate elements are allowed within a subtree?
>No.
* That would be incorrect. You are confusing binary trees with binary
search trees.
I don't think that I am confusing anything here.
* A binary tree doesn't impose any limitations whatsoever on the
contents of the nodes.
We have to distinguish the dublication of labels from the dublication of
nodes. In a tree, subtrees will not share nodes. However, different nodes
might share labels.
The definition that the OP refers to is clearly not talking about labelsbut
about nodes.
It only defines the structure of the tree (each
node can have one parent node and two subtrees).
And those subtrees do not share nodes.

Right.I was talking about nodes only. And I was not asking about
"Binary Search Tree" which seems to be a specialization of a Binary
Tree. The statement that subtrees do not share nodes in a binary tree
is in synch with the definition of "the subtrees are disjoint". Thanks
for validating my understanding.
* What you are thinking about is a binary search tree,
*which has the
additional limitation that all the nodes in the left subtree must be
smaller than the node itself, and the ones on the right subtree larger..
You are blurring the distinction of nodes and labels. That is not a good
idea when talking about trees. The comparison applies to labels. The
requirement that nodes be distinct is just a consequence of the absence of
cycles in trees.
Duplicate elements are allowed within a subtree?
No.

Right.
Recursively if we check I find that, since root and subtrees can not
have anything common, between root, left and right nothing is going to
be common in a binary tree. Hence now I am able to understand every
node value in a binary tree is Unique. Thanks

Thouh I don't know the significance of this Uniqueness.:(
Best
Kai-Uwe Bux- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
Okay....Okay... .Now I got it. It is that nodes or lables are distinct.
But the data storage I mean the values we store may be anything which
means that we may have redundant data in a tree.Interestin g....
Jun 27 '08 #6
Kai-Uwe Bux wrote:
We have to distinguish the dublication of labels from the dublication of
nodes. In a tree, subtrees will not share nodes. However, different nodes
might share labels.
I understood "no duplicate elements" to mean that the same value
cannot be stored in the tree twice. I apologize for the misunderstandin g.
Jun 27 '08 #7
On Jun 3, 2:06 pm, Kai-Uwe Bux <jkherci...@gmx .netwrote:
Vinodh wrote:
[...]
2) A binary tree is partioned into three disjoint subsets. That means
all the elements in a binary tree should be unique?
Yes.
Duplicate elements are allowed within a subtree?
No.
I'm not sure I like the wording here. "Duplicate" can (and
usually does, I think) mean a copy, and you can definitely have
elements with identical values (copies of one another) in a
tree. Each element, however, must be "unique", in the sense
that it has a distinct identity from all other elements.
Any significance of this?
Yes: trees do not have cycles.
There's more too it than that, I think. A tree is a directed
graph, but you can have acyclic directed graphs which aren't
trees. The important significance here is that each element
(except the root) has exactly one parent, no more (and the root
has zero). (In fact, the definition that I've usually heard for
a tree is a directed acyclic graph in which exactly one element
has zero elements pointing into it, and all other elements have
one element pointing into them. Although the recursive
definition proposed in the original posting works as well, and
results in the same thing.)

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jun 27 '08 #8

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

Similar topics

4
2021
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 use a fake sender address.
3
6714
by: Will Oram | last post by:
Hi, My assignment is to create a non-binary tree of arbitrary form, and then print out the data in an orderly fashion. The handout contains a tree to be inputted: 2 / | \ 3 7 5 / \ |
6
636
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. Any help would be greatly appreciated... Thank you,
11
2533
by: jova | last post by:
Is there a difference between a Binary Tree and a Binary Search Tree? If so can someone please explain. Thank You.
8
3131
by: [diegueus9] Diego Andrés Sanabria | last post by:
Hello!!! I want know if python have binary trees and more?
26
3000
by: Michel Rouzic | last post by:
I have a binary file used to store the values of variables in order to use them again. I easily know whether the file exists or not, but the problem is, in case the program has been earlier interupted before it could write the variables to the file, the file is gonna be empty, and then it's gonna load a load of crap into variables, which i want to avoid. That file is always 36 bytes big (it contains 4 double-precision floats and one...
8
7824
by: sudharsan | last post by:
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
1
2756
TMS
by: TMS | last post by:
I'm trying to write an address book that is based on a binary tree. I'm devloping in Visual C++ (I blew up my Ubuntu with the new dist, so no EMACS), starting with the basics: #ifndef binarySearchTree_h #define binarySearchTree_h #include <string> #include <iostream> using namespace std;
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9996
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3964
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3564
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.