Implement heap sort in place without heapq:
sift_down(a, i, n): restore the max-heap property for the subtree at i within a[:n]heapify(a): build a max-heap bottom-up in O(n)heap_sort(a): repeatedly swap the max to the end and shrink the heap; sorts a ascending in place and returns NoneUnlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.
Start 7-day free trial