Sorting algorithms/Heapsort: Difference between revisions

end = end-1 must go before sift down, or else the algo doesn't work. See Wikipedia for the correct Psuedocode
No edit summary
(end = end-1 must go before sift down, or else the algo doesn't work. See Wikipedia for the correct Psuedocode)
Line 13:
''last element of the heap)''</span>
swap(a[end], a[0])
<span style="color: grey">''(put the heap back in max-heap order)''</span>
siftDown(a, 0, end-1)
<span style="color: grey">''(decrement the size of the heap so that the previous''
''max value will stay in its proper place)''</span>
end := end - 1
<span style="color: grey">''(put the heap back in max-heap order)''</span>
siftDown(a, 0, end-1)
 
'''function''' heapify(a,count) '''is'''
Anonymous user