Pattern Recognition Drill
Easy Heaps
The Problem
Convert an arbitrary array into a min-heap in-place.
What approach would you use?
Think about it before scrolling down.
heapq.heapify does bottom-up sift-down. O(n) because most nodes are near the bottom.
Common Trap
Inserting elements one by one is O(n log n). heapify is O(n) — know the difference.