[理工] 台大資工 資結

作者: 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