PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > Empty binary trees
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Empty binary trees

Réponse
 
LinkBack Outils de la discussion
Vieux 03/06/2008, 12h03   #1
Vinodh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Empty binary trees

Started reading about Binary Trees and got the following questions in
mind. Please .

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
  Réponse avec citation
Vieux 03/06/2008, 13h06   #2
Kai-Uwe Bux
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut [OT] Re: Empty binary trees

Vinodh wrote:

> Started reading about Binary Trees and got the following questions in
> mind. Please .
>
> 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.programming.



Best

Kai-Uwe Bux
  Réponse avec citation
Vieux 03/06/2008, 15h37   #3
Juha Nieminen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [OT] Re: Empty binary trees

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.
  Réponse avec citation
Vieux 03/06/2008, 15h50   #4
Kai-Uwe Bux
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [OT] Re: Empty binary trees

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
  Réponse avec citation
Vieux 03/06/2008, 18h18   #5
Vinodh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Empty binary trees

On Jun 3, 7:50pm, Kai-Uwe Bux <jkherci...@gmx.net> wrote:
> 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

  Réponse avec citation
Vieux 03/06/2008, 18h35   #6
Vinodh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Empty binary trees

On Jun 3, 10:18pm, Vinodh <pvinodhku...@gmail.com> wrote:
> On Jun 3, 7:50pm, Kai-Uwe Bux <jkherci...@gmx.net> wrote:
>
>
>
>
>
> > 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.Interesting....
  Réponse avec citation
Vieux 03/06/2008, 20h16   #7
Juha Nieminen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [OT] Re: Empty binary trees

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 misunderstanding.
  Réponse avec citation
Vieux 04/06/2008, 09h56   #8
James Kanze
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Empty binary trees

On Jun 3, 2:06 pm, Kai-Uwe Bux <jkherci...@gmx.net> wrote:
> 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:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 18h28.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,17795 seconds with 16 queries