Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
用数组模拟二叉树,结点数肯定是2的一个幂,所以,向上靠拢In Reply To:Xiedie的解题报告里面,const int MAXX = 32000; //最大范围, int f[(MAXX+1)*3] //节点值. 为什么f是(MAXX+1)*3? 对于有n个节点的二叉树,*2不就够了吗? Posted by:Lucifer at 2005-09-05 08:09:57 *3是用多了空间的,*2很可能是空间不足的 要用N个结点,就要取 2^(log2(N)向上取整)这么个大小的数组,树根在数组下标0的话,左儿子在r*2+1, r*2+2,用惯了树根在1就+10安全第一 ~~~~~ Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator