Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write code for finding depth of tree

Answer Posted / om

struct tree //creating structure

{

int data; //data field of node

struct tree *lchild,*rchild;//left child & right child of node

};


//for depth calculation

int depth(struct tree *p)

{

int l,r;

if(p!=NULL)

{

l=depth(p->lchild);

r=depth(p->rchild);

return (1+((l>r)?l:r));

}

return -1;

}

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does malloc () calloc () realloc () free () do?

1060


Explain what is page thrashing?

1090


why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above

1152


write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);

2354


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1214


How to write a code for reverse of string without using string functions?

2139


What are Macros? What are its advantages and disadvantages?

1156


Explain how can I write functions that take a variable number of arguments?

1073


How can I remove the leading spaces from a string?

1155


Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings

2751


What is sorting in c plus plus?

971


What does emoji p mean?

1110


Tell us something about keyword 'auto'.

1070


write a program to generate address labels using structures?

4568


What are the similarities between c and c++?

1064