descending heap sort

Posted by user1 on Stack Overflow See other posts from Stack Overflow or by user1
Published on 2010-06-01T04:22:49Z Indexed on 2010/06/01 4:33 UTC
Read the original article Hit count: 174

Filed under:

use heap sort to sort this in descending order and show the steps or explanation please below is the tree

                             79
                       33           57
                    8     25    48

below is the array 79 - 33 - 57 - 8 - 25 - 48 ok ascending is easy because the largest element is at the top we can exchange the last element and the first element and then use heapify as the sample code in wikipedia describes it.

© Stack Overflow or respective owner

Related posts about heapsort