[理工] [資結]99交大資聯
4.Assume that a max heap is implemented in an array and we input the set of
numbers as "31,41,59,26,53,58,97."
(9)What's the final sequence of numbers in an array?
31 , 31 41 41 59 59 59 59
/ => / , / \ => / \ , / \ , / \ => / \ ,
41 31 31 59 31 41 31 41 31 41 53 41
/ / \ / \
26 26 53 26 31
59 59 59 59 97
/ \ / \ / \ / \ / \
53 41 => 53 58 , 53 58 => 53 97 => 53 59
/ \ / / \ / / \ / \ / \ / \ / \ / \
26 31 58 26 31 41 26 31 41 97 26 31 41 58 26 31 41 58
#
我最後的答案是(97,53,59,26,31,41,58) 可是選項裡沒這個答案
(10)Suppose that we perform "DeleteMax" that removes the maximal number from
the max heap and put this number in the last element od the array.What's
the sequence of numbers in the array after we execute the first DeleteMax
operation.
58 59
/ \ / \
remove 97 => 53 59 => 53 58
/ \ / / \ /
26 31 41 26 31 41
我的答案是(59,53,58,26,31,41,97) 選項裡也沒有..
是我哪裡做錯了嗎? 凡請指正
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.115.52.122
→
03/17 11:43, , 1F
03/17 11:43, 1F
推
03/17 11:44, , 2F
03/17 11:44, 2F
推
03/17 11:45, , 3F
03/17 11:45, 3F
→
03/17 12:01, , 4F
03/17 12:01, 4F
→
03/17 12:42, , 5F
03/17 12:42, 5F
→
03/17 12:42, , 6F
03/17 12:42, 6F
推
03/17 12:46, , 7F
03/17 12:46, 7F
推
03/17 12:47, , 8F
03/17 12:47, 8F
推
03/17 12:49, , 9F
03/17 12:49, 9F
推
03/17 12:51, , 10F
03/17 12:51, 10F
→
03/17 12:51, , 11F
03/17 12:51, 11F
→
03/17 14:27, , 12F
03/17 14:27, 12F
→
03/17 14:30, , 13F
03/17 14:30, 13F
→
03/17 14:31, , 14F
03/17 14:31, 14F
推
03/17 14:56, , 15F
03/17 14:56, 15F