Best video on this topic I've found so far. Thank you, professor 👍
@maryelainecaliff10 ай бұрын
I'm glad you found it helpful.
@kevinliu57502 жыл бұрын
Best Priority Queue tutorial video ever!!! Thanks Marry
@maryelainecaliff2 жыл бұрын
Thanks! I'm glad you found it helpful.
@ioannispallis72582 жыл бұрын
Thank you very much professor. With such professors you can be only good student.
@maryelainecaliff2 жыл бұрын
I appreciate the compliment.
@vipulbhardwaj15993 жыл бұрын
really nice visual representation of Dijkstra's, thanks a lot this really helped me with my assignment. :)
@maryelainecaliff3 жыл бұрын
I'm glad it helped.
@pseudolimao6 ай бұрын
This is it. If you don't understand dijkstra's with heaps, this demystifies it. I just looked at the code implementation and couldn't comprehend it, but this decomposition helped tremendously. The key takeaway is how the priority queue pushes down costly jumps to a node X, so when we get to that item in the queue, that node X will already be "marked" by a shorter path, meaning we can discard that item from the queue, essentially skipping steps. Moreover, since we push "up" the uncostly jumps, our "marks" essentially give us the shortest path to each node, meaning we can stop the algorithm as soon as we have marks equal to the number of nodes. If you imagine a big graph, you're going to "push down" into the queue a bunch of costly items, you're going to "mark" the nodes rather quickly, finding the shortest path as soon as you mark them all, and discarding a considerable amount of items in the process. Notice too, that if you have a huge number of edges, compared to vertices, you're doing a lot of work sorting edges in the queue, that you could spend doing lookups, so intuitively you can start being suspicious that this solution might be equal or worse than the naive approach. I am really pleased with what i unlocked watching this video, thank you Mary. You've also shown me i should, ideally, grab a pen and paper and just go through problems to understand them.
@maryelainecaliff6 ай бұрын
I'm glad you found the video helpful. I think you're right that the key to understanding is with the ideas and diagrams, because we don't get bogged down in the specifics of code. Then once we really understand what's going on, it becomes much easier to translate into code (in any language).
@pseudolimao6 ай бұрын
@@maryelainecaliff the code is just that, code for a set of ideas. and some key ideas, especially for these fundamental algorithms' optimized implementations, are very obfuscated within the code. From the array implementation to the priority queue one, the key takeaway is that sorting the queue by edge weight gives us the optimal edge as the first edge we process between those nodes (if one edge is always smaller than two, aka no negative weights), which is almost impossible to decipher this without brute forcing examples in your head/paper or having someone explain it to you, but it's really beautiful once you actually grasp the intention.
@ApoorvaRajBhadani3 жыл бұрын
Thanks for this great explanation! Greetings from India!
@maryelainecaliff3 жыл бұрын
You are certainly welcome. I'm glad you found it helpful.
@Lod5313 жыл бұрын
Thanks from ETH Switzerland! The visualization is brilliant.
@maryelainecaliff3 жыл бұрын
Thank you.
@frzhouu26762 жыл бұрын
Thanks from China, great explanation!
@maryelainecaliff2 жыл бұрын
You are welcome!
@ashraf35763 жыл бұрын
great explanation, really helped for my final exam, greeting from malaysia
@maryelainecaliff3 жыл бұрын
Terima kasih. Glad it helped.
@harishwarreddy29163 жыл бұрын
If possible try to explain these algorithms along with its pseudo-code.
@maryelainecaliff3 жыл бұрын
Thanks for the suggestion. However, you will find high-level pseudocode for the algorithm in the breadth-first-search video. The algorithm is largely the same, with the primary differences being the use of the priority queue and, of course, the use of the weight of each edge in the cost calculation.
@MissChelsie243 жыл бұрын
Best video I've seen on this!
@maryelainecaliff3 жыл бұрын
Thank you.
@SEYMABEYAZTAS-ib4bz Жыл бұрын
Is there an animated code of the dijkstra run in java? if they throw
@59sharmanalin2 жыл бұрын
Great walkthrough! I just want to confirm if (!sptSet[v] && graph[u][v] != 0 && dist[u] != Integer.MAX_VALUE && dist[u] + graph[u][v] < dist[v]) dist[v] = dist[u] + graph[u][v]; This condition is already addressed by PQ and should not be used to update distance array every-time we visit neighbours of selected vertex
@maryelainecaliff2 жыл бұрын
That's correct. We're moving from keeping track of the best cost seen so far in the cost array to putting that into the priority queue to manage for us.
@59sharmanalin2 жыл бұрын
@@maryelainecaliff Great, thanks!! Keep up the good work, below I just implemented the algo, it's very intuitive and easy algo
@anupritakasbekar81722 жыл бұрын
what is the time complexity and space complexity for this
@maryelainecaliff2 жыл бұрын
That actually depends on the implementation of your graph representation (adjacency list or adjacency matrix) and the implementation of your priority queue. For a discussion of some of the possibilities, you can check out www.baeldung.com/cs/dijkstra-time-complexity.
@shaniduplessis9102 Жыл бұрын
Great explanation, thank you!
@maryelainecaliff Жыл бұрын
Glad it was helpful!
@Tzyt23452 жыл бұрын
Thanks a lot for this tutorial. Helped me a lot !
@maryelainecaliff2 жыл бұрын
Glad to hear that!
@williamson-mcgee73653 жыл бұрын
Great tutorial!
@superneutral16632 жыл бұрын
thankyou very much. was very explained
@maryelainecaliff2 жыл бұрын
I'm glad you found it helpful.
@varalakshmimamillapalli99643 жыл бұрын
Thank you so much ...❤️❤️❤️♥️
@ShivamKendre-fc3su11 ай бұрын
Thank you so much
@maryelainecaliff11 ай бұрын
Glad you found it helpful.
@juandiegobermeo50293 жыл бұрын
just great, thank you very much!
@maryelainecaliff3 жыл бұрын
Glad you liked it!
@xX_dash_Xx2 жыл бұрын
why did we not include E in the graph, it's gonna feel excluded 😅
@xX_dash_Xx2 жыл бұрын
AND I
@xX_dash_Xx2 жыл бұрын
thank you for saving my ass this semester tho. great vid