heapsort in array · Fleeting Years
Heapsort is one of the algorithms for sorting, with average time complexity and worst , and space complexity . I think it's kind of interesting, so I write down the Java implementation here. Previously I was familar with the top-down (siftUp()
) method, but in this post I write down the buttom-up (siftDown()
) way, based on Wikipedia.
Firstly heapify()
using siftDown()
with time to build the max heap, then pop the top into the sorted part and siftDown()
the heap part to maintain the heap property. Most importantly,
Read full article from heapsort in array · Fleeting Years
No comments:
Post a Comment