卷別
資料結構與演算法
計算國立中興大學 2025 · 考試 · 第 25 題
考科資料結構
(10%) Consider a binary min-heap represented by the array , where the element 1 is at the root. Suppose you need to insert a new element, 4, into this min-heap. Describe the complete insertion process step-by-step. Your answer should include:
- Indicating where the new element is initially placed in the array.
- Explaining the heapify-up (or bubble-up) process in detail, showing each intermediate state of the heap after any necessary swaps.
- Presenting the final min-heap array once the insertion is complete.
Make sure to clearly justify the steps taken and the reasoning behind each comparison and swap, based on the fundamental properties of a min-heap.