[理工] 台大资工 资结

楼主: carlossp (weyuruiwysfjgnjf)   2015-02-03 20:26:44
小弟有几题问题想要问大家
98年资结 2.(4) Prove that the average height of the binary search tree
after inserting n integer values{1,2....n} in a random order
is O(logn).
这题毫无想法,只想到每次插入的可能性做高度平均,超复杂~~
作者: asjh612 (581)   2015-02-03 22:03:00
每个insert分别是O(lg1+lg2+..+lgn)=O(nlgn) 除n为average 所以是O(lgn) 不过这只是我的想法XDD不保证一定对XDD
作者: harryron9 (两个世界)   2015-02-03 22:19:00
觉得我的写法可能拿不到分 看看就好given a set {1,2....n} nodeseach node may be a leaf in same posibilitythus we know that in BST average serch time isO(lgn), for those leafs serch times = tree heightthen the BST will be average height O(lgn)
作者: galapous (墨)   2015-02-03 22:25:00
#1KbkLGsO

Links booklink

Contact Us: admin [ a t ] ucptt.com