Search⌘ K
AI Features

What Makes a Tree Balanced?

Explore how to identify if a binary tree is height balanced by calculating the height of each subtree and ensuring the difference does not exceed one. This lesson guides you through a step-by-step approach to check balance from leaf nodes to the root, helping you better understand tree structures for coding interviews.

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) |<= 1 ...