Heap Sort Quiz

Q1. A streaming service must output the 100 largest user-scores from a daily feed of 10 million scores without storing everything in memory. Which strategy best fits?




Q2. An engineer compares two heap-build procedures for sorting 1 million keys: (i) inserting each key into an empty heap, (ii) Floyd’s bottom-up heapify. What time-complexity difference will they observe?




Q3. To produce an ascending array with heap sort, which heap orientation and extraction order is correct?




Q4. A developer’s sift-down for a binary heap uses `while (2*i+1 < n)` as the loop guard on a 1-based index array. What bug is most likely?




Q5. When heap sort and merge sort both run on data that nearly fit the CPU cache, heap sort often loses despite O(n log n) ties. Why?




Q6. Which statement about heap sort’s stability and space usage is accurate?




Q7. Replacing a binary heap with a 4-ary heap in heap sort primarily reduces:




Q8. An interviewer asks why bottom-up heapify often beats repeated *sift-up* insertion in practice even when both fit in O(n) vs O(n log n) theory. The main runtime win comes from:




Q9. While profiling, you notice heap sort beating quicksort on a dataset of 500 identical keys and 500 random keys. The most plausible reason is:




Q10. In a system with strict 64 KB stack limits, which variant of heap sort is safest?




Q11. You must repeatedly extract the 50 largest items from a 10 000-element array without disturbing the remainder for later processing. Efficient practice is:




Q12. On a performance review, a candidate claims “heap sort with a ternary (3-ary) heap is always faster than binary.” Which corner case most disproves that?




data-structures-and-algorithms