Search⌘ K
AI Features

What makes a tree 'balanced'?

Explore how to assess if a binary tree is height-balanced by learning to calculate subtree heights and apply the balance condition. Understand the algorithm to verify balance from leaf nodes to root, helping you analyze tree structures effectively.

Introduction

A binary tree is height-balanced if, for each node in the tree, the difference between the height of the right subtree and the left subtree is at most one.

Height(LeftSubTree)Height(RightSubTree)<=1|Height(LeftSubTree) - Height(RightSubTree) ...