Tuesday, 10 March 2015

Number of nodes in a binary tree

A binary tree is a tree in which has every node has two child, except the root node. To calculate the number of nodes one can possibly say, at level 0, there is only one node i.e the root node, and then at each level the number of nodes are in power of 2. So this sums to $1 + 2^1 + 2^2 + 2^3 + ... + 2^k = 2^{k+1} - 1 / 2 - 1 = 2^{k+1} -1$

No comments:

Post a Comment