*這兩題解題時間是前面問題一、二的加總,感謝 台灣商管教材研發學會 的教學影片 問題一、是否為堆積樹(Heap tree)或二元搜尋樹(Binary search tree) 判斷Heap Tree的條件為 左右子節點都比其父節點大/小 即為最大/最小堆積樹 判斷Binary Tree的條件為 左子節點都比其父節點小而右 子節點都比其父節點大 即為二元搜尋樹 所以重點在於,判斷節點的大小 Private Function FindMax(nodes() As Integer, root As Integer, upperBound As Integer) As Integer If root > upperBound Then Return Integer.MinValue Dim t As Integer = Math.Max(FindMax(nodes, 2 * root + 1, upperBound), FindMax(nodes, 2 * root + 2, upperBound)) Dim Max As Integer = Math.Max(nodes(root), t) Return Max End Function 以遞迴方式,每個節點都會看做Root點,以判斷最大堆積樹為例 Private Function isMaxHeap(nodes() As Integer) As Boolean Dim U As Integer = nodes.GetUpperBound(0) Dim i As Integer = 0 For i = 0 To U If nodes(i) < FindMax(nod...