How would you like to learn today?
Visualize algorithms in real time, explore them step by step, or challenge yourself with a test.Choose a path to focus—or scroll down to preview all options.
Visualize the algorithm step-by-step with interactive animations in real time.
Read the full explanation, examples, and starter code at your own pace.
Drag and arrange the algorithm steps in the correct execution order.
🧠 Select Active to activate
Follow every state change, comparison, and transformation as the execution unfolds in real time.
📖 Select Passive to activate
(Shortest Path)Dijkstra’s algorithm is a classic method for finding the shortest path from a starting node to every other node in a weighted graph (with non-negative edge weights).
dist where every node’s distance is set to infinity (∞), except the start node which is set to 0.previous map to keep track of the best preceding node for each node (useful for reconstructing the shortest path).u with the smallest distance from the queue.v of u:
alt = dist[u] + weight(u, v)alt is less than dist[v]:
dist[v] to alt.previous[v] to u.v in the priority queue with the new distance.dist object contains the shortest distances from the start node to every other node.previous map.Consider the following graph:

Goal: Find the shortest path from node A to node D.
dist = { A: 0, B: ∞, C: ∞, D: ∞ }previous = {}[(A, 0)]alt = 0 + 1 = 1 → Update dist[B] = 1, previous[B] = A.alt = 0 + 4 = 4 → Update dist[C] = 4, previous[C] = A.[(B, 1), (C, 4)].alt = 1 + 2 = 3 → Update dist[C] = 3, previous[C] = B.alt = 1 + 5 = 6 → Update dist[D] = 6, previous[D] = B.[(C, 3), (C, 4), (D, 6)]alt = 3 + 1 = 4 → Update dist[D] = 4, previous[D] = C.[(D, 4), (D, 6)].previous[D] = Cprevious[C] = Bprevious[B] = A🎯 Select Challenge to activate
Drag and arrange the algorithm steps in the correct execution order instead of spending time typing code letter by letter.
The algorithm is divided into three logical parts. Carefully rearrange each section in the correct order to form a complete and valid solution.
Understand Below AlgorithmGreen text means the instruction is placed in the correct position.
Red text means the instruction is in the wrong position.
Instructions with the same background color indicate particular blocks start and end.
A tick mark means the instruction is correct and locked.
🔒 Locked steps cannot be moved. Only unlocked steps are draggable.
🔊 Enable sound for swap feedback and completion effects.