Count the number of nodes in a given binary tree. | Algorithms
Objective: Given a binary tree, write an algorithm to count all the nodes in the tree. Do postorder traversal. If root is null return 0. (base case all well for the recursion) if the root is not null then make a recursive call to left child and right child and add the result of these with 1 ( 1 for counting the root) and return.
Post to Tumblr