Write a C program to determine the number of elements (or size) in a tree.
October 28, 2007 · Filed Under C Interview Questions, Placement Questions
![]() Don't want to miss a single bit? Subscribe By Email for Daily Jobs |
Try this C program
int tree_size(struct node* node)
{
if (node==NULL)
{
return(0);
}
else
{
return(tree_size(node->left) + tree_size(node->right) + 1);
}
}
Related Articles
- Write a C program to determine the number of elements (or size) in a tree.
- Write a C program to find the mininum value in a binary search tree.
- Write a C program to find the mininum value in a binary search tree.
- Write C code to check if a given binary tree is a binary search tree or not?
- Write a C program to create a mirror copy of a tree (left nodes become right and right nodes become left)!


