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

看板Prob_Solve作者 (旅人)時間6年前 (2017/12/04 09:46), 6年前編輯推噓2(202)
留言4則, 3人參與, 6年前最新討論串1/1
大家好, 最近在做資料結構的練習,但有一些疑問,還請各位前輩指點,謝謝! 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?) -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 42.116.28.98 ※ 文章網址: https://www.ptt.cc/bbs/Prob_Solve/M.1512351989.A.0F2.html

12/04 10:26, 6年前 , 1F
因為 root 是 0
12/04 10:26, 1F

12/04 13:17, 6年前 , 2F
嗯、要看 root 是 0 還是 1 而定。
12/04 13:17, 2F
※ 編輯: smilesaline (42.116.28.98), 12/04/2017 15:56:44

12/05 04:18, 6年前 , 3F
2. 應該是9 comprisons沒錯@@
12/05 04:18, 3F

12/05 04:19, 6年前 , 4F
*comparisons
12/05 04:19, 4F
文章代碼(AID): #1Q9AZr3o (Prob_Solve)