473,804 Members | 3,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2697
da***********@y ahoo.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.hel sinki.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***********@y ahoo.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.programmin g.

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***********@y ahoo.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.programmin g.

--

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 "technicall y correct" English; but since when was rock & roll "technicall y correct"?
Nov 13 '05 #5

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

Similar topics

4
2832
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 put my .cpp and my .h code below. Please help and thank you very much. // include files #ifndef BINTREE_H #define BINTREE_H #include <iostream> #include <iomanip>
7
2904
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 enumerating the complete filepath to every file it seems the smarter way (faster, more memmory efficient) is to model the filesystem treestructure in a abstract tree - and having only the filenames & node pointer in an Array. struct tree {
4
9023
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, even the removal, I just don't know how to keep track of the parent, so that I can set its child to the child of the node to be removed. IE - if I had C / \ B D
5
9581
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
1997
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 something to do with dynamic data object ? thanx for your help. ================== begin of code ============================== #include <stdio.h> #include <stdlib.h>
6
3671
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
8674
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 radix sorting program and was surprised by its speed. Therefore, I'd like help with a radix tree program in order to compare it with a prior binary tree program that I finished. The parts I'm having trouble with are collecting statistics and...
1
4814
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 following code called trouble.C. The probem is nodes.push_back(node); line. The error message I get is below. What is the cause for this? Do I need a constructor? I am compiling it on Fedora. Nandor
20
2412
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; struct treenode *left; struct treenode *right;
0
9706
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
10326
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10317
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
10075
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
6851
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
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
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
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.