You are viewing a single comment's thread. Return to all comments →
Because in maxHeap we need to put all the items which are less than items in the minHeap.
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
In this sequence 1, 2, 3, 4, 5 should be part of maxHeap
And, 6, 7, 8, 9, 10 shoul de part of minHeap.
So that every time we can pick median in one operation:-
Seems like cookies are disabled on this browser, please enable them to open this website
Heaps: Find the Running Median
You are viewing a single comment's thread. Return to all comments →
Because in maxHeap we need to put all the items which are less than items in the minHeap.
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
In this sequence 1, 2, 3, 4, 5 should be part of maxHeap
And, 6, 7, 8, 9, 10 shoul de part of minHeap.
So that every time we can pick median in one operation:-