• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
June 29, 2022 |32.9K Views

Determine if a binary tree is height-balanced

  Share  1 Like
Description
Discussion

A tree where no leaf is much farther away from the root than any other leaf. Different balancing schemes allow different definitions of “much farther” and different amounts of work to keep them balanced.


Consider a height-balancing scheme where the following conditions should be checked to determine if a binary tree is balanced.

For each node make two recursion calls – one for left subtree and the other for the right subtree. 


Based on the heights returned from the recursion calls, decide if the subtree whose root is the current node is height balanced or not. 


If it is balanced then return the height of that subtree. Otherwise, return -1 to denote that the subtree is not height balanced.

Determine if a binary tree is height-balanced : https://www.geeksforgeeks.org/how-to-determine-if-a-binary-tree-is-balanced/