- Thread starter
- #1

I have an algorithm which goes as follows:

int CN(struct node *node)

{

if(node==null)

return 0;

return 1 + CN(node->left) + CN(node->right);

}

My question is that how to calculate the complexity of the above code and what is the complexity in terms of number of nodes n.

The answer that I'm guessing is O(nlogn). But the answer is given as O(n); I'm clueless how to approach to get O(n)?