I think the simplest way is to see it this way. Min PQ means that if x < y we poll x first then y. If x is equal to y, it makes no difference since they have same priority. We might as well poll x first then y. The rule becomes x y, we poll x first then y. f x is equal to y, it makes no difference since they have same priority. We might as well poll x first then y. The rule becomes x >= y. The point is that Min and Max PQ differ in their polling strategy depending on if x is greater than or less than y. When two elements have the same value, both strategies behave the same.
Great Work @WilliamFiset, I have a question, regarding priority queues with numbers, by multiplying it by -1 to negotiate it and make the largest number is the smallest. what if the numbers include a ZERO, that will make it the largest, right?
If the earlier heap prioritized the max value, then largest number come out of the queue first. Zero would be the smallest number and come out of the queue last (assuming no negative numbers). If we negate everything to implement a min queue, Zero would be the largest number and come out of the queue first (since all the previously positive numbers are now negative).
1:54 there is a typo I guess... The two cases (normal and negated) as written result to the same thing... I mean: 1. if x>=y : x comes before y 2. if x
I think the confusing part is: if you do the negation thing, it results in the same thing as if you build a max-heap from the same numbers used in the min-heap. People are confused because its calles min-heap to max-heap, but after transforming, you still pull the smallest element first after the min-heap principle. Probably its just the naming of min-heap to max-heap. If its called "access min-heaps in reversal order", everything would be fine. And thats actually the same as building a max-heap from the original values.
@@xRandom112 but I still don't get if 13 is greater than 11, 11 should come out first as if x>=y, y comes out first. Can you or the video owner make this clear to me please?
@ismail bagga is it like after the negation, 2 becomes the largest number and 13 becomes the smallest so following the min heap property, 13 comes out first making this act like a max heap?