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.
+5
A:
Read about Heapsort here. A nice pseudocode has also been provided.
Prasoon Saurav
2010-01-03 12:03:15
+1
A:
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.
Martinho Fernandes
2010-01-03 12:18:28
This should be a comment, not an answer. Also, if you want C answers, you should tag your question with the C tag. And since this homework, don't expect full code answers, that would be against the spirit.
Martinho Fernandes
2010-01-03 14:57:14