473,386 Members | 1,609 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,386 software developers and data experts.

A doubt about C's tree data struct

I am just a beginner in tree data – struct. I have this little doubt.
Left node ‘weights' lesser than the right one. I have seen, so far it
is algorithm implementations. But why not vice-versa that is right
node ‘weights' lesser than the left one? Why the trees are implemented
in that way? Can any body clarify?

Thanks in advance
Nov 13 '05 #1
4 2666
da***********@yahoo.com scribbled the following:
I am just a beginner in tree data – struct. I have this little doubt.
Left node ‘weights' lesser than the right one. I have seen, so far it
is algorithm implementations. But why not vice-versa that is right
node ‘weights' lesser than the left one? Why the trees are implemented
in that way? Can any body clarify?


You haven't told us the definition of a node "weighing" something. So
your whole question is meaningless.
But I suspect that you are merely experiencing implementation-dependent
behaviour. The C standard does not specify anything about how
implementations must implement structure fields.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"I wish someone we knew would die so we could leave them flowers."
- A 6-year-old girl, upon seeing flowers in a cemetery
Nov 13 '05 #2
dam_fool_2003 writes:
I am just a beginner in tree data - struct. I have this little doubt.
Left node 'weights' lesser than the right one. I have seen, so far it
is algorithm implementations. But why not vice-versa that is right
node 'weights' lesser than the left one? Why the trees are implemented
in that way? Can any body clarify?


I think it is arbitrary, just like reading text left to right in most of the
world. I suppose it might possibly have something to do with people being
right handed. And why is that? And so on.
Nov 13 '05 #3
Greetings.

In article <a3**************************@posting.google.com >,
da***********@yahoo.com wrote:
I am just a beginner in tree data – struct. I have this little doubt.
Left node ‘weights' lesser than the right one. I have seen, so far it
is algorithm implementations. But why not vice-versa that is right
node ‘weights' lesser than the left one? Why the trees are implemented
in that way? Can any body clarify?


Simple convention; theoretically you could implement it either way. The
tradition probably stems from the fact that binary tree data structures
were invented and/or popularized in the Western world, where text and
sorted lists are usually written left to right. Hence, it's more natural
for us to put "lesser" things on the left and "greater" things on the
right.

Note that tree data structures are not unique to C, and as your question
doesn't seem to concern a C implementation in particular, this question is
probably better off in a more general newsgroup such as comp.programming.

Regards,
Tristan

--
_
_V.-o Tristan Miller [en,(fr,de,ia)] >< Space is limited
/ |`-' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= <> In a haiku, so it's hard
(7_\\ http://www.nothingisreal.com/ >< To finish what you
Nov 13 '05 #4
Groovy hepcat da***********@yahoo.com was jivin' on 5 Oct 2003
06:07:42 -0700 in comp.lang.c.
A doubt about C's tree data struct's a cool scene! Dig it!
I am just a beginner in tree data – struct. I have this little doubt.
Left node ‘weights' lesser than the right one. I have seen, so far it
is algorithm implementations. But why not vice-versa that is right
node ‘weights' lesser than the left one? Why the trees are implemented
in that way? Can any body clarify?


Your subject line is nonsensical. C doesn't have a "tree data
struct". And your question has nothing whatsoever to do with C. It is
an algorithm question that doesn't even make much sense. Please ask
more clearly in a more appropriate newsgroup, such as
comp.programming.

--

Dig the even newer still, yet more improved, sig!

http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technically correct" English; but since when was rock & roll "technically correct"?
Nov 13 '05 #5

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

Similar topics

4
by: Henry Jordon | last post by:
I have everything pretty much done but I need to fix something in my coding. I want to be able to enter strings such as "love", "hate", "the", etc. but am unable to figure how to do this. I have...
7
by: Casper | last post by:
In scanning a drive and comparing file content, I need to remember filepaths to every single file I encounter so I can take actions on certain files later on. Rather than having a huge list...
4
by: Tarique Jawed | last post by:
Alright I needed some help regarding a removal of a binary search tree. Yes its for a class, and yes I have tried working on it on my own, so no patronizing please. I have most of the code working,...
5
by: pembed2003 | last post by:
Hi, I have a question about how to walk a binary tree. Suppose that I have this binary tree: 8 / \ 5 16 / \ / \ 3 7 9 22 / \ / \ / \
7
by: sugaray | last post by:
the binary search tree node here contains another structure as it's data field, programs did successfully work when data field is int, char, this time i got stucked, don't know why ? if there's...
6
by: sathyashrayan | last post by:
#include<stdio.h> #include<stdlib.h> #include<string.h> struct tree { int data; struct tree *left,*right; }; void init(struct tree *node)
1
by: Foodbank | last post by:
Hi, I'm currently teaching myself C data structures in preparation for a job transition and I've just passed the point in which radix sorting was covered in my book. I've recently finished a...
1
by: nandor.sieben | last post by:
I have an n-ary tree implementation consisting of a header file. I include this ntree.hh file and an example code below called ntree.C. All this seems to be working. I have a problem with the...
20
by: DemonFox | last post by:
i have started my midterm exersize than is on binary treescan anyone help me on the basics i have started and i have made the following on my tree.h file: struct treenode { int data;...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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,...
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...

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.