Height is
- Show the height of BST that maintains balance property is .
This section is an optional reading!
In a BBST, unlike a regular BST, it is guaranteed that the tree's height is . This claim can be easily observed for a perfect BST, where each internal node has two children and all the leaves are at the same level.

Let's observe the perfect BSTs above
Height | Nodes | Binary Log Calculation |
---|---|---|
Given these perfect BSTs, one can intuit how this holds more generally.
First, convince yourself that the worst height of a BST is when it has the minimum number of nodes concerning its height. Then, let's call the minimum number of nodes given height.
The worst case is when .
If we find the upper bound of for BBST, then we've bounded the height of all BBSTs.
Let's consider a BBST of height and the minimum number of nodes . This tree is composed of a root and two subtrees. Since the whole tree has the minimum number of nodes for its height, so do the subtrees. For the big tree to be of height , one of the subtrees must be of height . To get the minimum number of nodes, the other subtree is of height .
Why can't the other subtree be of height or ?
Because the balance property requires the height of siblings to differ by at most .
So far, we established for ,
We know
therefore
If then , therefore
We can keep doing this
What does the above expression demonstrate? Why is that significant?
This expression demonstrates that the number of nodes at least doubles each time the height increases by a factor of . This observation is important because is exponential in . Therefore is logarithmic in the number of nodes.
Continuing the proof, we see that this can be written as:
The largest we can put in there is :
Why is this value of chosen as ?
This allows the expression to be equal to either or , depending on if is even or odd.
- Even :
- Odd :
So we have:
So we showed the minimum number of nodes, in a BBST of height , is at least :
What does this say about height, ? First, let's take the logarithm of both sides:
So, .