Implemented the median maintenance algorithm using max and min heaps.