Sorting algorithms/Heapsort: Difference between revisions

Content added Content deleted
(end = end-1 must go before sift down, or else the algo doesn't work. See Wikipedia for the correct Psuedocode)
m (Another sync with the WP pseudocode)
Line 17: Line 17:
end := end - 1
end := end - 1
<span style="color: grey">''(put the heap back in max-heap order)''</span>
<span style="color: grey">''(put the heap back in max-heap order)''</span>
siftDown(a, 0, end-1)
siftDown(a, 0, end)