Construct a custom Binary Heap from scratch and solve the continuous Running Stream Median problem:
std::vector<int> heap.void push(int val): Adds element and performs sift-up to preserve min-heap invariant.void pop(): Replaces root with last element and performs sift-down.int top() const: Returns minimum element in $O(1)$.int size() const and bool empty() const.void addNum(int num): Inserts number and rebalances heap sizes in $O(\log N)$.double findMedian() const: Returns exact median in $O(1)$ time.push, pop, top).5, 15, 1, 3, 2, 8, 7 and display running median after each insertion.=== Custom MinHeap Test === Extracted Min elements: 2 4 7 10 15 === Running Stream Median Test === Add 5 -> Median: 5.0 Add 15 -> Median: 10.0 Add 1 -> Median: 5.0 Add 3 -> Median: 4.0 Add 2 -> Median: 3.0 Add 8 -> Median: 4.0 Add 7 -> Median: 5.0 [✓] Binary Min-Heap & Stream Median verified (Time: 0.008s, Memory: 2.2 MB)