The size of a Tree is the number of nodes (including root) present in the tree.
xxxxxxxxxx
// Calculating the size of a Binary Search Tree
class Solution {
// Recursively calculating the size
public int sizeOfTree (TreeNode root) {
if (root == null)
return 0;
return 1 + (size(root.leftChild) + size(root.rightChild));
// Here ".leftChild" is the left node and for right is the right node
}
}