Algorithms

Tree height

The height is the number of edges from the root to the farthest leaf. A node's depth is the number of edges from the root to that node.

Example

In the chain 1 → 2 → 5 → 8, the depth of 8 is 3 and the tree's height is also 3.

Test yourself: Tree height

Binary trees

The root of any tree has depth ___.

Lessons that use it

More algorithms terms

All terms →

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.