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

Why dont c comments nest?

999


How do I copy files?

996


how to construct a simulator keeping the logical boolean gates in c

2195


I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...

10138


How are variables declared in c?

1023


How do you determine the length of a string value that was stored in a variable?

1078


Explain can you assign a different address to an array tag?

1011


Write a program to check prime number in c programming?

1028


The statement, int(*x[]) () what does in indicate?

1080


What is the g value paradox?

1104


write a program to print data of 5 five students with structures?

2004


Synonymous with pointer array a) character array b) ragged array c) multiple array d) none

1009


What are the Advantages of using macro

1112


One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.

2581


What do you mean by a local block?

1026