Building a scheduler heap from an array

A job scheduler receives the priority array [29,14,36,8,23,17][29,14,36,8,23,17], where smaller numbers indicate higher priority. Construct a binary min-heap in place using zero-based indices and bottom-up heap construction.


Process internal indices 22, 11, and 00, in that order. At each index, sift down by swapping with the smaller existing child whenever necessary. Continue until that subtree satisfies min-heap order. The children of index ii are at 2i+12i+1 and 2i+22i+2 when those indices exist.


A complete binary tree contains the initial array entries in level order.


Complete every array entry after each entire sift-down finishes. Enter exact integers; priorities are unitless.

Completed sift-downIndex 0Index 1Index 2Index 3Index 4Index 5
After index 2
After index 1
After index 0

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Heaps Questions: