Computer Science
Intermediate

Nodes in a Full Binary Tree

Total nodes in a perfect binary tree of height h.

Formula

N=2h+1−1N = 2^{h+1} - 1

Live Calculator

Members

Variables

hHeight

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

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026