Understanding height balanced binary trees
Now we know why we cannot use a complete binary tree to implement a balanced binary search tree. Our implementation of a balanced binary tree should have a weaker balancing condition for it to be practically useful. We need the tree to always perform well and be easy to create, validate, and rebalance. Keeping this in mind, we define a balanced binary tree as the following.
A height-balanced binary tree is a tree where, for every node in the tree, the absolute difference between the height of the left and right subtree is at most 1
This definition is less restrictive than the definition of the most optimal binary search tree possible with N nodes (complete tree). It allows the tree to have a height or absolute balance factor that is not the minimum possible for every node. Let us look at a few examples of generic balanced binary search trees.
Liking the course? Check our discounted plans to continue learning.