how to build heap tree?
问题 I understand the algorithm of building heap tree (max or min) but i don't understand the code of it: First: How does this loop build a max heap?, why we started the i with n/2-1 ? // Build heap (rearrange array) for (int i = n / 2 - 1; i >= 0; i--) heapify(arr, n, i); and this is the Heapify function: Secondly: how did we assume that largest is "i" ? Third: why we heapify again in the last line? // To heapify a subtree rooted with node i which is // an index in arr[]. n is size of heap void