Skip to content
ENExplore Calculators

Tree Height And Nodes Calculator

Work out tree height and nodes instantly with clear inputs, formula shown and shareable results.

About Tree Height And Nodes Calculator

A perfect b-ary tree of height h has bᵏ nodes at level k, so the total is the geometric sum (b^(h+1) − 1)/(b − 1). The deepest level alone holds bʰ leaves.

Formulas

Total nodes

N = (b^(h+1) − 1) / (b − 1)

Leaves

L = bʰ

Worked example

With the default values below, Tree Height And Nodes Calculator returns Total nodes of 121. Change any input above and every figure here is recalculated in your browser.

Inputs used

Branching factor (children per node)accepts 1–50
3
Height (root is level 0)accepts 0–40
4

Results

Total nodes
121
Leaf nodes
81
Internal nodes
40
Nodes at the deepest level
81

Step by step

  1. 1Values used
  2. 2Total nodes
  3. 3Leaves
  4. 4Total nodes= 121
  5. 5Leaf nodes= 81
  6. 6Internal nodes= 40
  7. 7Nodes at the deepest level= 81

Assumptions and limits

  • The result is derived only from the 2 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to whole numbers, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

A ternary tree of height 4?

(3⁵ − 1)/2 = 121 nodes, of which 81 are leaves.

Why does search take O(log n)?

Because n grows exponentially with height, so the height — and hence the search depth — grows only logarithmically with n.

Tree Height And Nodes Calculator | Calcrivo