Heap Sort with Your Own Sift-Down

medium
Unit 10 · Sliding Windows0/3 to milestone

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 None
Pro problem

Unlock 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
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Heap Sort with Your Own Sift-Down · TechGradify