[问题]几个关于资料结构的疑问

楼主: smilesaline (旅人)   2017-12-04 09:46:27
大家好,
最近在做资料结构的练习,但有一些疑问,还请各位前辈指点,谢谢!
1. In a complete binary tree, what is the index number of the parent of
the node numbered 20?
Ans: 9 (为什么不是10?)
2. How many comparisons would the insertion sort make on an array of
10 elements that is already in ascending order?
Ans: 7 (为什么不是9?)
作者: yr (Sooner Born Sooner Bred)   2017-12-04 10:26:00
因为 root 是 0
作者: springman (司布林)   2017-12-04 13:17:00
嗯、要看 root 是 0 还是 1 而定。
作者: dhowdy (丹尼尔黄)   2017-12-05 04:18:00
2. 应该是9 comprisons没错@@*comparisons

Links booklink

Contact Us: admin [ a t ] ucptt.com