By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,780 Members | 1,520 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,780 IT Pros & Developers. It's quick & easy.

A doubt about C's tree data struct

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.