所屬科目:公職◆資料結構
一、給予如下二元樹節點的宣告,分別寫出 C 的遞迴程式計算二元樹節點個 數及計算二元樹葉節點(leaves)個數(Count the number of nodes in a binary tree and count the number of leaf nodes in a binary tree, respectively)。 (25 分)
二、給予如下二元樹節點的宣告,寫一 C 的遞迴程式 swapTree(NODEPTR tree)將每一節點的左、右節點互換(Swap the left and right children of every node of a binary tree)。 (25 分)
三、給予如下程式,假設 x[] = [30, 75, 53, 47, 21, 94, 88, 39],lb = 0,ub = 7, 請問執行完下列程式後,x[]的內容為何?(25 分)