Write code for finding depth of tree
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / crispin
/*
* Simple tree node representation
*/
struct node_t {
struct node_t *left;
struct note_t *right;
};
/*
* Return the maximum depth of the tree given a pointer
* to its root node.
*/
unsigned int
tree_depth (node_t *root)
{
return (NULL == root) ? 0 :
MAX(tree_depth(root->left, root->right)+1);
}
| Is This Answer Correct ? | 3 Yes | 6 No |
printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions
Write a program for finding factorial of a number.
I have an array of 100 elements. Each element contains some text. i want to: append a star character to the end of every fifth element remove every second character from every tenth element, and… add a line feed (ascii 10) after the 30th character of every array element whose length is greater than 30 characters.
how to print the character with maximum occurence and print that number of occurence too in a string given ?
Tell me can the size of an array be declared at runtime?
Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?
please give me a VIRTUSA sample palcement papers.... you will only send TECHNICAL SECTION..... that is help for me Advance Thanks........................
write a program to print data of 5 five students with structures?
main() { static char *s[]={"black","white","yellow","voilet"}; char **ptr[]={s+3,s+2,s+1,s}, ***p; p=ptr; **++p; printf("%s",*--*++p+3); }
What is meant by initialization and how we initialize a variable?
What are header files why are they important?
What are linked lists in c?