A doubt about C's tree data struct

D

dam_fool_2003

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
 
J

Joona I Palaste

(e-mail address removed) 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 ([email protected]) ---------------------------\
| 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
 
T

Tristan Miller

Greetings.

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
 
O

osmium

dam_fool_2003 said:
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.
 
P

Peter Shaggy Haywood

Groovy hepcat (e-mail address removed) 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"?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top