Heap / Priority Queue — Reasoning Check

Apply the module invariants, traces, and boundary conditions.


Get every question correct to pass this checkpoint. You can review feedback, revise your answers, and submit again.

1. What is the third-largest element of [9,4,9,2,7], counting duplicate occurrences as separate ranks? Enter one integer.
2. A frequency table is {10:4, 20:2, 30:2, 40:1}, and k=2. Which acceptance rule correctly handles the cutoff tie?

Select one answer.

3. KSmallestPairs receives A=[1,1], B=[0,0,2], and k=6. A solution deduplicates output pairs by their displayed values and returns only [1,0] and [1,2]. What is wrong?

Select one answer.

4. For sorted A=[-5,-1,4,8], sorted B=[-2,3], and k=2, the pair-sum heap seeds only rows i=0 and i=1. Why may rows i>=2 be omitted?

Select one answer.

5. A MedianFinder receives 8, then 2, then 5, then 11. What median should it return after the fourth insertion? Enter the numeric value.
6. IPO starts with capital w=1 and permits at most three projects. The (required capital, profit) pairs are (1,2), (3,-5), and (4,4). What should the optimal process do?

Select one answer.

Join Discord