Data Structures19 sections · 729 units
Open in CourseQuiz: Two Heaps
Insertion order
Check Your Understanding
In the two-heaps median solution, why do we always add to max-heap first, then transfer to min-heap?
- A.To make the code simpler
- B.Because max-heap is for larger elements
- C.To ensure the element ends up in the correct heap through comparison with max-heap root
- D.It doesn't matter which heap we add to first