median and heaps