17 August, 2015

12 August, 2015

Suppose there is a tree , now starting from root node, if the distance to left-most child node equals to the distance to the right-most child node, we can calculate the total number of tree nodes of directly. Since we don't have to scan every node of the tree, the time complexity of algorithm is .