Тёмный

Priority Queue Min Heaps and Max Heaps 

WilliamFiset
Подписаться 180 тыс.
Просмотров 63 тыс.
50% 1

Опубликовано:

 

10 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 20   
@middleverse3838
@middleverse3838 4 года назад
Definitely don't understand why y comes out first, not x @1:29. Doesn't that also mean its a min heap?
@isaacdouglas1119
@isaacdouglas1119 4 года назад
Yes, he means this would still result in a min heap though his previous slide makes it sound like the goal of the negation is to create a max heap.
@middleverse3838
@middleverse3838 3 года назад
@@yutaitadori7318 lmao. Very productive.
@subee128
@subee128 5 месяцев назад
Thanks
@gandhiisback3940
@gandhiisback3940 4 года назад
I still don't understand why you keep the equality when negating the comparator. Can you please explain why it's x >= y not x > y?
@aryasarthak9919
@aryasarthak9919 4 года назад
i am new to ds but i think it is because to implement stable sorting
@FICHEKK
@FICHEKK 3 года назад
Because negating a zero still gives a zero.
@abhineelnandi9552
@abhineelnandi9552 3 года назад
As stated it's there to make the sorting algorithm stable.
@adityasrirambhaskara4309
@adityasrirambhaskara4309 3 года назад
When x == y , both the values are same. So which value comes out first doesn't make a difference. i.e x in case of x
@AD-ox4ng
@AD-ox4ng 9 месяцев назад
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.
@ashrafmohamed3896
@ashrafmohamed3896 3 года назад
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?
@kshitijshekhar1144
@kshitijshekhar1144 2 года назад
it won't make a difference.
@AD-ox4ng
@AD-ox4ng 9 месяцев назад
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).
@erggish
@erggish 7 лет назад
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
@WilliamFiset-videos
@WilliamFiset-videos 7 лет назад
Hey Chris, I think my slides are correct, let me explain. In a min PQ if x = y and now y is the smaller element and it should come out first.
@teelee3543
@teelee3543 6 лет назад
Yes, the point here is to make sure you wanna get a min PQ, right ?
@xRandom112
@xRandom112 4 года назад
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.
@aryanmishra7310
@aryanmishra7310 3 года назад
@@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?
@aryanmishra7310
@aryanmishra7310 3 года назад
@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?
@birzhanamirov8715
@birzhanamirov8715 Год назад
Can we has minmax, too? en.m.wikipedia.org/wiki/Min-max_heap
Далее
Priority Queue Inserting Elements
9:59
Просмотров 67 тыс.
Constructors Are Broken
18:16
Просмотров 107 тыс.
Introducing iPhone 16 | Apple
02:00
Просмотров 4,1 млн
The Most Elite Chefs Ever!
00:35
Просмотров 6 млн
Heaps, heapsort, and priority queues - Inside code
19:01
2.6.3 Heap - Heap Sort - Heapify - Priority Queues
51:08
Premature Optimization
12:39
Просмотров 803 тыс.
How Binary Search Makes Computers Much, Much Faster
6:51
Indexed Priority Queue (UPDATED) | Data Structures
25:22
Rust: When C Code Isn't Enough
8:26
Просмотров 160 тыс.
Heaps & Priority Queues in Python
15:57
Просмотров 63 тыс.
WHY IS THE HEAP SO SLOW?
17:53
Просмотров 221 тыс.
Jonathan Blow on how an operating system should work
14:22