Concept Flow - Median of Data Stream Using Two Heaps
New number arrives
Compare with max-heap top?
Push to max-heap
Balance heaps size difference <=1
Calculate median
Output median
New numbers go into one of two heaps (max-heap for smaller half, min-heap for larger half). We keep heaps balanced, then median is top of one or average of both.
