Nodes in a Full Binary Tree
Total nodes in a perfect binary tree of height h.
Live Calculator
MembersVariables
Example
A full binary tree of height 3 has 2⁴ − 1 = 15 nodes.
How it works
In a perfect binary tree, every level is completely filled and each node has exactly two children until the last level. The number of nodes doubles at each step: 1 at the root, 2 on the next level, 4 after that, and so on up to level h. Adding these levels gives 1 + 2 + 4 + ... + 2^h, which is a geometric series that sums to 2^(h+1) - 1.
When to use it
Use this formula when you know a binary tree is perfect and you need the total number of nodes from its height. It is common in data structures, tree algorithms, and analyzing the size or memory cost of complete tree-based representations.
Worked example, step by step
A perfect binary tree has height h = 4. Substitute into the formula: N = 2^(h+1) - 1 N = 2^(4+1) - 1 N = 2^5 - 1 N = 32 - 1 N = 31 So the tree has 31 nodes.
Common mistakes to avoid
- Using this formula for any binary tree, even when the tree is not perfect
- Confusing height with the number of levels and plugging in the wrong value of h
- Forgetting the minus 1 at the end and writing only 2^(h+1)
Did You Know?
A full binary tree of height h holds 2^(h+1)−1 nodes — growth that explains why balanced trees stay shallow.
Share this formula
More in Computer Science
View allShannon Entropy
AdvancedAverage information content of a random source (bits).
Master Theorem (form)
AdvancedAnalyzes running time of divide-and-conquer algorithms.
Hamming Distance
AdvancedNumber of positions at which two strings differ.
Bits to Represent n
BasicMinimum number of bits to represent n distinct values.
Binary to Decimal
BasicConverts a binary number to decimal.
Decimal to Binary
BasicConvert a decimal number to binary by dividing by 2 and reading remainders.