diff --git a/C06-Heapsort/6.1.md b/C06-Heapsort/6.1.md index d67acc45..bd7879e7 100644 --- a/C06-Heapsort/6.1.md +++ b/C06-Heapsort/6.1.md @@ -37,9 +37,9 @@ It must be in the leaf node. Is an array that is in sorted order a min-heap? ### `Answer` -没有说明是递增数组还是递减数组,所以不一定. +如果假设按排序排序,则排序顺序是递增的,那么是的,因为对于被视为父节点的任何索引i,左子级子由(2 * i)给出,右子级子由(2 * i)给出+1。在排序数组中,这两个索引都将在父节点的右侧,因此更大或相等。因此,这满足了Heap属性,可以认为是最小堆. -We don't know whether it's an increasing order or descending order. +If you assume by sorted, that it is in increasing sorted order, then yes, because for any index i considered as a parent node, the left subchild is given by (2*i) and right subchild is given by (2*i)+1. In a sorted array, both these indices will be to the right of the parent node and therefore larger or equal. Therefore this satisfies the Heap property and it can be considered a min-heap. ### Exercises 6.1-6 ***