Moody
Moody

Reputation: 33

Heap Sorting Algorithm

I need the algorithm of HeapSort for sorting the elements of the array, such that all the elements of the array i.e [19 18 14 15 5 7 13 3 8] are in non-decreasing order.

Upvotes: 1

Views: 1623

Answers (3)

Z0dCHiY8
Z0dCHiY8

Reputation: 1

Actually, you can use IF-free (branchless) heap sort

Upvotes: 0

Prasoon Saurav
Prasoon Saurav

Reputation: 92854

Read about Heapsort here. A nice pseudocode has also been provided.

Upvotes: 4

R. Martinho Fernandes
R. Martinho Fernandes

Reputation: 234354

Heapsort is pretty simple. You grab all elements, put them in a heap (in your case, a max-heap) in any order and then grab them back from the heap (with the delete-max operation) and they come all sorted up.

Upvotes: 1

Related Questions