Concept Flow - Median of Data Stream Using Two Heaps
New number arrives
Compare with max-heap top
Add to max-heap
Balance heaps size
Calculate median
Output median
New numbers go to max-heap or min-heap based on comparison. Heaps are balanced to keep sizes close. Median is top of max-heap or average of tops.
