Monday, January 16, 2012

Counting number of elements in a tree

int count(node * root)
{
if(!root)
return 0;
else
return(1+count(root->left)+count(root->right));
}

No comments: