 Specifically, sometimes the root is placed at index 1, in order to simplify arithmetic.Let "n" be the number of elements in the heap and "i" be an arbitrary valid index of the array storing the heap.If the tree root is at index 0, with valid indices 0 through "n − "1, then each element "a" at index "i" has
Alternatively, if the tree root is at index 1, with valid indices 1 through "n", then each element "a" at index "i" has

This implementation is used in the heapsort algorithm, where it allows the space in the input array to be reused to store the heap (i.e.