A response-time logger retains the five smallest readings seen so far using a binary heap containing exactly five readings. It has already processed 626262, 454545, 575757, 282828, and 39 ms39\ \text{ms}39 ms, and all five are currently retained.
The logger then receives these readings in order:
Choose either a min-heap or a max-heap so that each new reading can be accepted or rejected by comparing it only with the root. Whenever a reading belongs among the five smallest seen so far, replace the root with that reading and restore heap order. Otherwise, discard the new reading. All readings are distinct.
Report the required heap type, the total number of root replacements during these six arrivals, and the largest retained response time after all arrivals. Enter the replacement count as an exact integer and the response time in milliseconds to zero decimal places.
Unlock full course notes by signing up
Array contents after delete-min
A binary min-heap is stored in a 0-indexed array, so the children of index iii are at indices 2i+12i+12i+1 and 2i+22i+22i+2. The array currently holds:
2, 6, 4, 11, 8, 5, 9, 13, 12, 10
One delete-min (extract-min) operation is performed using the standard method: remove the root, move the last element into the root position, shrink the array by one, and sift that element down. Enter the value stored at each index of the nine-element array after the operation.
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][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 222, 111, and 000, 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 iii are at 2i+12i+12i+1 and 2i+22i+22i+2 when those indices exist.
Complete every array entry after each entire sift-down finishes. Enter exact integers; priorities are unitless.