資料結構›Ch9 進階樹
第 7 題/共 88 題
◀ DS 7/88
7. Heap Merge、Binary Tree
#DS-09-007中Heap MergeBinary Tree

A Maximum Binary Tree (abbreviated as MaxBT) is defined as a binary tree that adheres to the max-heap property without the necessity of following the complete binary tree property. In a MaxBT, each node pp consists of a value (p.datap.data) and two links (p.leftp.left and p.rightp.right) pointing to the left and right children, respectively. A link to nil indicates the absence of further children.

The provided pseudocode, although incomplete, implements a recursive function for merging two MaxBTs into a single MaxBT. This function takes the root nodes of the two MaxBTs (root1root1 and root2root2) as input and returns the root node of the merged MaxBT.

1: function MergeMaxBinaryTrees(root1root1, root2root2) 2: if root1root1 = nil then return (a) end if 3: if root2root2 = nil then return (b) end if 4: if root1.data>root2.dataroot1.data > root2.data then 5: (c) ←\leftarrow MergeMaxBinaryTrees( (d) , (e) ) 6: return (f) 7: else 8: (g) ←\leftarrow MergeMaxBinaryTrees( (h) , (i) ) 9: return (j) 10: end if 11: end function

Assuming all the blanks in the above function have been appropriately filled to ensure its proper functioning, please select the correct description(s) below.

📄 台大113
跳轉到第題
▤完整推導請見《WH 資工筆記 · 資料結構》Ch9 進階樹
本章題號 · 1–20 / 88