04 Jun 2021 - Hadron DaVinci
Sort the given array with Heap Sort:
A = [5, 2, 4, 6, 1, 3]
heap_sort(A)
assert(A) == [1, 2, 3, 4, 5, 6]
Create Max Heap
Complexity
Time Complexity: N
Space Complexity: N
Same as Method1 but done directly on input array.
Complexity
Time Complexity: NlogN
Space Complexity: 1