previous | start | next

Why balanced?

Easy! We want the put and get methods to be O(log(N)) instead of O(N).

The height of a binary search tree is the longest path from the root to a null link.

The height of a binary search tree with N keys determines the number of comparisons in the worst case for both put and get.

If the tree is unbalanced some paths will be short at the expense of making other paths longer with the worst unbalanced case where there is only 1 path of length N - 1.



previous | start | next