Concept Flow - Median of Data Stream Using Two Heaps
New number arrives
Compare with max-heap root
Add to max-heap
Balance heaps if size difference > 1
Calculate median from roots
Output median
New numbers go to one of two heaps (max-heap for smaller half, min-heap for larger half). Heaps are balanced to keep sizes close. Median is from roots.
