Build a Heap-Based Task Scheduler

sift up/down and O(n) heapify

Challenge 3 of Indexes & StructuresIntermediate~55 min

Build a binary min-heap from scratch and grow it into a real task scheduler. You will implement push and sift-up, then pop and sift-down, an O(n) heapify, a priority queue that breaks ties by insertion order, and finally a top-K selector. No heapq, no imports, just an array and the parent/child index math that makes heaps fast.

5 steps

  1. 1Push and sift up
  2. 2Pop and sift down
  3. 3Heapify in O(n)
  4. 4A priority queue with stable ties
  5. 5Top-K with a heap
Start step 1