Introduction to Height Balanced Binary Tree - GeeksforGeeks
Introduction to Height Balanced Binary Tree - GeeksforGeeks
The difference between the heights of the left and the right subtree
for any node is not more than one.
The left subtree is balanced.
The right subtree is balanced.
https://www.geeksforgeeks.org/introduction-to-height-balanced-binary-tree/?ref=asr10 1/10
2/14/25, 10:57 AM Introduction to Height Balanced Binary Tree - GeeksforGeeks
If the right subtree is taller, the height balance of the node will be
positive.
If the left subtree is taller, the balance of the node will be negative.
https://www.geeksforgeeks.org/introduction-to-height-balanced-binary-tree/?ref=asr10 2/10
2/14/25, 10:57 AM Introduction to Height Balanced Binary Tree - GeeksforGeeks
Proof:
https://www.geeksforgeeks.org/introduction-to-height-balanced-binary-tree/?ref=asr10 3/10
2/14/25, 10:57 AM Introduction to Height Balanced Binary Tree - GeeksforGeeks
The above tree is a binary search tree and also a height-balanced tree.
Suppose we want to find the value 79 in the above tree. First, we
compare the value of the root node. Since the value of 79 is greater than
35, we move to its right child, i.e., 48. Since the value 79 is greater than
48, so we move to the right child of 48. The value of the right child of
node 48 is 79. The number of hops required to search the element 79 is
2.
Similarly, any element can be found with at most 2 jumps because the
height of the tree is 2.
https://www.geeksforgeeks.org/introduction-to-height-balanced-binary-tree/?ref=asr10 4/10
2/14/25, 10:57 AM Introduction to Height Balanced Binary Tree - GeeksforGeeks
Use recursion and visit the left subtree and right subtree of each
node:
Check the height of the left subtree and right subtree.
If the absolute difference between their heights is at most 1
then that node is height-balanced.
Otherwise, that node and the whole tree is not balanced.
https://www.geeksforgeeks.org/introduction-to-height-balanced-binary-tree/?ref=asr10 5/10
2/14/25, 10:57 AM Introduction to Height Balanced Binary Tree - GeeksforGeeks
Master Data Structures and Algorithms at your own pace with our
DSA Self-Paced course. In just 90 days, you’ll cover core concepts,
solve real-world problems, and sharpen your problem-solving
skills. Take the Three 90 Challenge: complete 90% of the course in
90 days and get a 90% refund. Stay motivated, track progress, and
achieve DSA mastery. Start today!
Similar Reads
Comparison between Height Balanced Tree and Weight Balanced Tree
What is Height Balanced Tree? Self-Balancing binary search trees are the
height-balanced binary tree is one for which at every node, the absolute…
4 min read
Create Balanced Binary Tree using its Leaf Nodes without using extr…
Prerequisites: Binary Tree to Doubly Linked ListGiven a Binary Tree, the
task is to create a Balanced Binary Tree from all the leaf nodes of the…
15 min read
Registered Address:
K 061, Tower K, Gulshan Vivante
Apartment, Sector 137, Noida, Gautam
Buddh Nagar, Uttar Pradesh, 201305
Advertise with us
Company Explore
About Us Job-A-Thon Hiring Challenge
Legal Hack-A-Thon
Privacy Policy GfG Weekly Contest
Careers Offline Classes (Delhi/NCR)
In Media DSA in JAVA/C++
Contact Us Master System Design
GFG Corporate Solution Master CP
Placement Training Program GeeksforGeeks Videos
Geeks Community
Languages DSA
Python Data Structures
Java Algorithms
C++ DSA for Beginners
PHP Basic DSA Problems
GoLang DSA Roadmap
SQL DSA Interview Questions
R Language Competitive Programming
Android Tutorial
https://www.geeksforgeeks.org/introduction-to-height-balanced-binary-tree/?ref=asr10 8/10
2/14/25, 10:57 AM Introduction to Height Balanced Binary Tree - GeeksforGeeks
https://www.geeksforgeeks.org/introduction-to-height-balanced-binary-tree/?ref=asr10 9/10
2/14/25, 10:57 AM Introduction to Height Balanced Binary Tree - GeeksforGeeks
DSA/Placements Development/Testing
DSA - Self Paced Course JavaScript Full Course
DSA in JavaScript - Self Paced Course React JS Course
DSA in Python - Self Paced React Native Course
C Programming Course Online - Learn C with Data Structures Django Web Development Course
Complete Interview Preparation Complete Bootstrap Course
Master Competitive Programming Full Stack Development - [LIVE]
Core CS Subject for Interview Preparation JAVA Backend Development - [LIVE]
Mastering System Design: LLD to HLD Complete Software Testing Course [LIVE]
Tech Interview 101 - From DSA to System Design [LIVE] Android Mastery with Kotlin [LIVE]
DSA to Development [HYBRID]
Placement Preparation Crash Course [LIVE]
Clouds/Devops GATE
DevOps Engineering GATE CS & IT Test Series - 2025
AWS Solutions Architect Certification GATE DA Test Series 2025
Salesforce Certified Administrator Course GATE CS & IT Course - 2025
GATE DA Course 2025
GATE Rank Predictor
https://www.geeksforgeeks.org/introduction-to-height-balanced-binary-tree/?ref=asr10 10/10