Source: http://math.univ-lyon1.fr/irem/IMG/pdf/heapsort_avec_solutions.pdf