Average height of a binary search tree

后端 未结 7 2328
执笔经年
执笔经年 2021-01-03 04:19

How do you compute the average height of a binary search tree when adding 1000 random ints? What is the average height?

7条回答
  •  醉梦人生
    2021-01-03 04:53

    it depends on the order the are added. If you start with the smallest value then the tree will be deeper because all new values will be added to the right child BST. If you add the largest value first then the left child will be deep while the right is empty.

提交回复
热议问题