Dijkstra's Algorithm is a greedy algorithm that finds the shortest path from a source node to all other nodes in a weighted graph by repeatedly selecting the nearest unvisited node and relaxing its edges (updating distances if shorter paths are found), with time complexity O(E log V) using adjacency lists and O(V²) using adjacency matrices, but it cannot handle negative edge weights.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Dijkstra's Algo in 2 Minutes | All you need to know #dijkstra #graph #dsa #algorithms #shorts #recapAdded:
Hello everyone. Let us have a quick recap about the Dijkstra's algorithm.
Just the way the Google Map works that given a source as well as a destination, it finds you the smallest path.
This particular Dijkstra works in the same way.
So, what is this Dijkstra's algorithm basically? It is a single source shortest path algorithm that helps you to find the shortest path from one particular source node to all the other nodes.
Which data structure does this Dijkstra works on? This particular Dijkstra basically works on the weighted graph.
And which programming paradigm does it follow?
Because it is an optimization problem, because you are trying to find the minimum travel cost or minimum distance, so this is a minimization problem, so we can apply greedy over here. And how does it apply greedy? Because all the time it is trying to pick the local optimal nearest neighbor first. Okay. Now, how does it work?
This particular Dijkstra's algorithm starts with the source node and assigns the value like the source to source is zero and to all other node, the distance becomes infinite. Now, it goes to the nearest unvisited node and it relaxes all the edges. And what do I mean by relaxing? Relaxing means updating the distance if a shorter distance is found.
Then once the relaxation is done, it keeps on doing the same thing until and unless all the nodes are covered. This is the way this Dijkstra is working.
Now, if you see one of the major drawbacks of Dijkstra is it cannot work on negative weighted edge. But when you will be seeing the Bellman-Ford, this particular drawback will be gone because Bellman-Ford can tackle this thing.
Now, what about the time complexity of this Dijkstra?
If we are doing using the adjacency list concept, the time complexity is order of E log V, where E is the number of edges and V is the number of vertices. And if we are doing using the adjacency matrix, in that case the time complexity becomes order of V squared.
So, this is all the things you wanted to know or you needed to know when we talked about this Dijkstra.
So, I hope all the things are clear and I have a detailed video on this Dijkstra available on the doubt playlist. I'm putting that in the pin comment. You can check out. Thank you for watching and stay tuned for the next video.
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
🚀 BCS613C Compiler Design | Module 1 to 5 Schema Evaluation 🔥 | VTU 6th Sem 💯 #VTU #bcs613c #exam
Pranavaa-y4y
104 views•2026-06-02











