Algorithms

Balanced tree

A tree where, at every node, the heights of the 2 subtrees differ by at most 1. That keeps its height at about log n.

Example

With 1 million nodes, a balanced tree has a height of about 20; a lopsided one can reach almost 1 million.

Test yourself: Balanced tree

Binary trees

Every perfect binary tree is also complete.

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.