今天要說的是min-max heap的問題
12 -------min
╱ ╲
30 29 -------max
╱ ╲ ╱ ╲
13 14 15 16 -------min
╱ ╲ ╱ ╲ ╱ ╲ ╱ ╲
17 18 19 21 22 23 24 25 -------max
assumpt that node X=12 belongs to min-level so that node12 is the minimum
in both left and right subtrees of node12.
assumpt that node X=26 belongs to max-level so that node29 is the maximum
in both left and right subtrees of node29.
12
╱ ╲
TL(30) TR(29) 12 is the minimum
29
╱ ╲
TL(15) TR(16) 29 is the maximum
If Tree is:
19 ----------min
╱ ╲
30 35 ----------max
╱ ╲ ╱ ╲
20 21 22 23 ----------min
╱ ╲ ╱ ╲ ╱ ╲ ╱ ╲
24 25 26 27 28 29 31 36
we see the node36 > node35, so error occurs,
node36 should be amended. Becoming the node that its number is smaller than 35
以上, 有錯請指教^^