previous | start | next

Maximum Height of a Binary Search Tree

Easy!

For a binary search tree with N keys and height, h, maximum height occurs if every node has a null link so that the tree is essentially a linked list:

 h = N - 1
   

The worst case number of comparisons for a search is height + 1.

So the worst case for an ordinary binary search tree is

      h + 1 = N
   

So the cost for the get method is O(N) in the worst case for a binary search tree.



previous | start | next