Dijkstra's Algorithm | Algorithm Interview | Skill-Lync Resources
Medium Algorithms Graph Algorithms

Explain Dijkstra's algorithm for shortest path.

Answer

Dijkstra's finds shortest paths from a source to all vertices in a weighted graph with non-negative edges. Use priority queue (min-heap) storing (distance, vertex). Start with source at distance 0, others at infinity. Extract minimum, update neighbors if shorter path found (relaxation). Time complexity is O((V+E) log V) with binary heap, O(V^2) with array. Doesn't work with negative edges - use Bellman-Ford instead.

Master These Concepts with IIT Certification
IIT Certified

Master These Concepts with IIT Certification

175+ hours of industry projects. Get placed at Bosch, Tata Motors, L&T and 500+ companies.

Relevant for Roles

Software Engineer Backend Developer Algorithm Developer