Python Program for Heap Sort
Pre-requisite: What is Heap Sort?
Heapsort is a comparison-based sorting technique based on a Binary Heap data structure. It is similar to selection sort where we first find the maximum element and place the maximum element at the end. We repeat the same process for the remaining element.
Sorted array is 5 6 7 11 12 13
Time Complexity: O(n*log(n))
- The time complexity of heapify is O(log(n)).
- Time complexity of createAndBuildHeap() is O(n).
- And, hence the overall time complexity of Heap Sort is O(n*log(n)).
Auxiliary Space: O(log(n))
Please refer complete article on Heap Sort for more details!