1

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.

3
  • In what programmin language you need it? Commented Jan 3, 2010 at 12:07
  • It is okay to ask here, but wikipedia usually has very good articles on algorithms. Commented Jan 3, 2010 at 12:17
  • 1
    "Non-decreasing" as in "increasing"? Commented Jan 3, 2010 at 12:29

3 Answers 3

4

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.