Find median from data stream
Split the numbers into a smaller half and a larger half. A max heap holds the smaller half and a min heap the larger, kept within one of each other in size — so the median is always at their tops.
sorted shows both halves in order: the median is where they meet. Below it, leftQueue and rightQueue are the two PriorityQueue arrays drawn as trees.