Indexed Priority Queue (UPDATED) | Data Structures

  Рет қаралды 26,806

WilliamFiset

WilliamFiset

Күн бұрын

Пікірлер: 32
@rico5146
@rico5146 4 жыл бұрын
Always thank you for uploading gorgeous videos william! btw, i noticed that at 20:47, i think sz = sz -1 should be located before swap (i, sz) cuz sz-1 point the last node of the heap.
@WilliamFiset-videos
@WilliamFiset-videos 4 жыл бұрын
Oops, that's a small bug. I looked in the source code I wrote for the IPQ and the size is decremented before the swap: github.com/williamfiset/Algorithms/blob/master/src/main/java/com/williamfiset/algorithms/datastructures/priorityqueue/MinIndexedDHeap.java#L124
@rico5146
@rico5146 4 жыл бұрын
WilliamFiset Thank you william!
@UdayTejaOriginal
@UdayTejaOriginal 4 жыл бұрын
I kept the following 3 handy to understand easily: 'val' : input is keyIndex, output is Value 'pm' : input is keyIndex, output is position 'im' : input is position, output is keyIndex
@tkingless
@tkingless Жыл бұрын
Must thank for this, much better than somewhere else I read
@tuantranluuquoc2910
@tuantranluuquoc2910 2 жыл бұрын
Man, the explanation can't get any better!!! Your lecture is such a treat to me as a self-taught programmer (though I still go to uni but my uni sucks a**...). Keep up the good work!
@jimmychu0807
@jimmychu0807 Жыл бұрын
Thank, great explanation! This video helps me solve a problem I faced currently!
@mehmanismayilov9317
@mehmanismayilov9317 4 жыл бұрын
That is awesome explanation of less known but useful Data Structure IPQ
@PLAZMAKE
@PLAZMAKE 4 жыл бұрын
I was literally watching the old video and just saw this one. What a coincidence!
@jckimis
@jckimis 4 жыл бұрын
Just FYI, if you need further information for Indexed PQ, please see "2.4 Priority Queues" in Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne. @William, it's a really awesome lecture!
@David-iq1kd
@David-iq1kd 9 ай бұрын
What is the best way to persist your indexed priority queue into and reconstitute it from a database? Would a graph database be better suited to this? Is there a strategy for only reacting to the differential of the indexed priority queue that's saved to a database so you don't need to pull the entire queue every time, so that you can be notified immediately when the priority queue is updated (or especially being able to listen for when specific instances have their priority updated - like you're waiting in line and need to know when your place changes, without having to poll the database?)
@liviur23
@liviur23 4 жыл бұрын
The meaning of key indices (aka. ki) seems to overlap with the other two entities: names and positions in the binary heap. A ki is a stable (does not change across heap operations) key for a value but the name is also a stable key for a value. A ki is used to index into an array but the position number can also index into an array. So why not just map the names (which I believe are the proper keys used by client code) to the positions and reduce the number of mappings needed?
@sahilanower9189
@sahilanower9189 3 жыл бұрын
My mind is going out of my indices after watching this!
@erikjohnson9112
@erikjohnson9112 4 жыл бұрын
OK, now code this all on the whiteboard while I tell you about my cat Mittens, and the cutest things she does. [session 1 of 6 for today's interviews]
@carnaqe1154
@carnaqe1154 9 ай бұрын
why do we have to map between keys and heapindexes? can we not just map keys directly to heap indexes and omit the two arrays which are just for mapping?
@rachitsingh8040
@rachitsingh8040 4 жыл бұрын
Hi William, Can you confirm if the min heap formed with key and value pairs is correct? Based of my understanding, min heap before performing any IPQ operations should be this: 0- (ki=7,v=1), 1-(ki=6,v=2), 2-(ki=0,v=3), 3-(ki=11,v=4), 4-(ki=9,v=5), 5-(ki=8,v=6), 6-(ki=4,v=7), 7-(ki=5,v=9), 8-(ki=2,v=11), 9-(ki=1,v=15), 10-(ki=10,v=16), 11-(ki=3,v=17) I sorted it by value. The arrangement is different than what I see in the video. What am I missing in my understanding here?
@WilliamFiset-videos
@WilliamFiset-videos 4 жыл бұрын
Min heaps aren't unique, so it's possible to have different trees depending on insertion order and where nodes are placed. The only thing that really matters is that the heap invariant is satisfied, i.e smaller values before larger values
@timmmmmmmmmmmmmmmmmmmmmmmm
@timmmmmmmmmmmmmmmmmmmmmmmm 3 жыл бұрын
Great video! What is the motivation for using this approach over hash table (aka hash map) to achieve O(logn) delete or decrease / priority value (for dijkstra)
@andreytamelo1183
@andreytamelo1183 4 жыл бұрын
What about 'remove by key' followed by 'insert by key' scenario?After the 'remove' we should have a hole in the 'key-to-index' table.. What should the behavior be? Re-index? If not, how do we figure out the next key index we want to assign? Keep a separate min heap of free indexes to assign?:)
@renetchi
@renetchi 4 жыл бұрын
I still don't understand why the im inverse map is pointing to different person with different value?
@alexandrep4913
@alexandrep4913 Жыл бұрын
separate the IM (inverse mapping) from the other two structures and it would make alot more sense to you. Then the index of the IM is the node index and the index of the vals and pm is the key index. Hope that makes sense!
@Aashishkumar-dg4op
@Aashishkumar-dg4op 4 жыл бұрын
Please upload the videos related to centroid Decompositon.
@alexandrep4913
@alexandrep4913 Жыл бұрын
I think your inverse mapping in the example is wrong or maybe the vals and PM are? Like you say "which person (key) is being represented in the node at index position 3". You then point to node at position 3, which has the ki of 8 but the value is 17 even though the node is 6. Are the values maybe wrong? Edit, no, your Inverse mapping is wrong. They need to match the key indexes or the array index given. Otherwise everything is wrong. Edit2, I am wrong lmao. It looks like Inverse mapping is an entirely separate entity from the other two arrays and the key index.
@mikemihay
@mikemihay 4 жыл бұрын
Thank you!
@Justicewarrior795
@Justicewarrior795 4 жыл бұрын
James has an arrow in his leg. Loool
@Spine223
@Spine223 7 ай бұрын
blud just saved me
@tumblerwater4361
@tumblerwater4361 4 жыл бұрын
What a dark example William exemplary video anyways.
@enyinnaukattah2083
@enyinnaukattah2083 Жыл бұрын
Poor Akarsh
@thallium54
@thallium54 4 жыл бұрын
wow i'm early
@ahmadbodayr7203
@ahmadbodayr7203 2 жыл бұрын
READ ABOUT ISLAM WILLIAM ❤
Indexed Priority Queue | Data Structure | Source Code
8:34
WilliamFiset
Рет қаралды 6 М.
Sparse Table Data Structure
23:18
WilliamFiset
Рет қаралды 32 М.
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
Priority Queue Introduction
13:18
WilliamFiset
Рет қаралды 479 М.
Lowest Common Ancestor (LCA) Problem | Eulerian path method
17:02
WilliamFiset
Рет қаралды 46 М.
Mountain Scenes | Dynamic Programming
15:42
WilliamFiset
Рет қаралды 10 М.
Priority Queue Inserting Elements
9:59
WilliamFiset
Рет қаралды 70 М.
Tools EVERY Software Engineer Should Know
11:37
Tech With Tim
Рет қаралды 21 М.
Union Find - Union and Find Operations
10:53
WilliamFiset
Рет қаралды 259 М.
Priority Queue Code
15:50
WilliamFiset
Рет қаралды 41 М.
OpenAI's o1 just hacked the system
26:31
AI Search
Рет қаралды 19 М.
Queue Introduction
6:26
WilliamFiset
Рет қаралды 28 М.
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН