PROBLEM DESCRIPTION
Given a binary tree, find its size (Total number of Nodes in the tree).
SOLUTION
1
2
3
4
5
6
7
8
9
10
11
class Tree
{
public static int getSize(Node root)
{
if(root == null) return 0;
int s1 = getSize(root.left);
int s2 = getSize(root.right);
return 1 + s1 + s2;
}
}