Be the first user to complete this post
|
Add to List |
47. Find the Size of the Binary Tree
Objective: Given a Binary tree, Find the size of the tree.
Note : The size of the tree is the number of nodes in the tree
Example :
![Size-of-Binary-Tree-example](/static/media/algorithms/2015/11/Size-of-Binary-Tree-example-1.png)
Approach :
- Very Simple solution
- Start from the root.
- Size = 1 (for the root) + Size Of left Sub-Tree + Size Of right Sub-Tree
- solve the left sub-tree and right sub-tree recursively.
![](/static/media/algorithms/2015/11/Size-of-Binary-Tree-Implement.png)
Size of the Tree is: 7