Перейти к содержимому

Why Dijkstra Works (and When It Fails)

BigOCast

0:00 / 0:00

Why Dijkstra Works (and When It Fails)

42 просмотра · 6 дн. назад
BigOCast
389 подписчиков
42 просмотра · 6 дн. назад
Why does Dijkstra’s algorithm work, and which mistakes break it? We begin with a 2–3 minute recap of the delivery example and Python from Part 1, then explain the reasoning behind each important rule. You’ll see why the smallest unfinished distance can be finalized, why finding the destination is too early to stop, and how a negative edge breaks that guarantee. We then trace a zero-cost cycle, explain strict improvement and tied routes, handle an unreachable destination, and derive time and memory use from the actual lazy-heap implementation. New to the algorithm or its Python implementation? Start with Part 1:    • Dijkstra’s Algorithm: How to Code it Properly   Runnable Python and tested edge cases: https://github.com/bigocast/bigocast-... The valid implementation rejects negative weights. The negative-cost run in this lesson deliberately bypasses that check to demonstrate why the contract matters. Equal-cost routes may have different shapes; this function returns one shortest route. 00:00 Final already? Opening and recap 02:14 The guarantee and its limit 04:32 Discovery, finalization, and outdated offers 06:31 Equal routes and zero-cost cycles 09:36 Unreachable destinations and start equals goal 10:55 Derive time and memory from the Python 14:31 The guarantee behind the result 15:15 Keep learning with BigOCast Which algorithm would you like explained next? Tell us in the comments. #Dijkstra #Python #Algorithms