Sir what is the explanation behind putting the element which is smaller than the current median in a maxHeap on the left side and if the element is greater than the current median then putting it in a minHeap on the right side?
Q.MEDIAN IN A RUNNING STREAM OF INTEGERS?
hi @Mukul-Shane-1247687648773500, u need to get the maximum amongst smaller elements and smallest amongst bigger element.
left side contains 2 3 4
right side contains 5 6 9
now if another element gets added it will only be affected by 4 or 5 suppose greater than 5 comes than 5 will be ans or less than 4 comes than 4 will be ans , similar case can be derived for equal to 5
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.