473,406 Members | 2,371 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,406 software developers and data experts.

Trees implimentation...!!!PLZ HELP!

momotaro
357 100+
this is the structer:
Expand|Select|Wrap|Line Numbers
  1. typedef struct tree Tree;
  2. struct tree{
  3. int value;
  4. Tree *left,
  5.        *right;
  6. };
plz which of the following implimentations is more accurate:

Expand|Select|Wrap|Line Numbers
  1. int TreeSize(Tree *root){
  2. int count = 0;
  3. if(root == NULL) return 0;
  4. else{
  5.       TreeSize(root -> left); count++;
  6.       TreeSize(root ->right); count++;
  7.       return count;
  8.       }
  9. }
*********************************OR*************** *************

Expand|Select|Wrap|Line Numbers
  1. int TreeSize(Tree *root){
  2. int h1,h2;
  3. if (root == NULL) return 0;
  4. else{
  5.        h1 = TreeSize(root -> left);
  6.        h2 = TreeSize(root -> right);
  7.        return (h1+h2+1);
  8.        }
  9. }
P.S:if there is any other suggestions go ahead!
THK!
Apr 25 '07 #1
1 996
Ganon11
3,652 Expert 2GB
The second one is better, because it is the only one that works.

The first function always returns 2.
Apr 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: jag | last post by:
Well i created couple of separate database using DBCA without oracle jvm, multimedia, example db, xml db coz for our databases we did not need it. Now to manage those databases i use EMC but to...
0
by: Liza K. | last post by:
I need a help from your side.....after making a test in Mic-Application center test , whenever i want to stat a test it gives me an error ( could not start the test.provider load failure (...
2
by: arman | last post by:
Hi, I am newbie in php and i am having some probs. This is a cool forum and i ask for your help. so plz help me if u can. Here is my prob -- I am using domxml to read and write data from...
2
by: Murali | last post by:
Hi, Friends plz help me to get any fullversion of dotnet2003 assemblies obfuscator, i found few obfuscators which are trail/evaluation versions!!, if i get crack for those i would be very...
1
by: zalan | last post by:
plz help me in creatin username and password for a software develpoed in 9i database and 6i forms. i hve create a table in database(login). that form should hve enter,cancel,and exit buttons. its...
2
by: rkgarimella9 | last post by:
Friends, i'm facing with a severe problem while coding an windows application. the problem is that i'm using a usercontrol consisting of three labels upon which three images are placed. the problem...
8
by: abhradwip | last post by:
I want to write a program which will find the shortest path between n no. of cities using dijkstra's algorithm ...... but could not do it..... i have written a program which will give the shortest...
3
momotaro
by: momotaro | last post by:
am trying to impliment the Interchange trees is this function is correct? int Interchange(Tree *root, Tree **newroot){ Tree *temps; if (root){ temp =...
1
by: vivekshekar | last post by:
Hi, I have a query qith me. ppl plz help me to solve this. I wrote a php prog to generate a out put text file. The output is from database. now the problem is i coverted this output file...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.