0PricingLogin
Competitive Programming Academy · Lesson

Dijkstra with a Heap

Greedy shortest paths on non-negative edges.

The Shortest-Path Problem

You want the cheapest route from one node to every other node. Dijkstra solves this when every edge weight is zero or positive.

The Greedy Idea

Dijkstra is greedy: it always expands the unvisited node with the smallest known distance, trusting that distance is final.

All lessons in this course

  1. Dijkstra with a Heap
  2. 0-1 BFS with a Deque
  3. Bellman-Ford & Negative Edges
  4. Floyd-Warshall All-Pairs
← Back to Competitive Programming Academy