Two Heap Technique
Learn Two Heap Technique (Heap, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
The General Pattern Behind Median From Data Stream "Two heap" is a named technique: split a dataset into two balanced halves using a max-heap for the lower half and a min-heap for the upper half, maintaining the invariant that every lower-half element ≤ every upper-half element. It solves any problem needing fast access to a MIDDLE point in a dynamically changing dataset - not just plain medians.