I am currently doing a max-heap. When I use remove() method, I understand that I would swap with the larger children. What if both of the children have the same priority? for instance
Case 1:
heap = [5,7,7,16,15]
if I remove 5 and replace it with 15, I would trickle down to the right (which is wrong), so I would trickle down to the left side.
but using the same logic, if i have
heap = [5,7,7,16,15,18]
and I trickle down left, it will no longer be a valid heap.
What can I do to ensure I have a valid heap?