[問題]幾個關於資料結構的疑問

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