Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 46s1 days 16 hours 1 minutes 46 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 46s1 days 16 hours 1 minutes 46 seconds.

Sign in to watch this lesson
Algorithms - Graphs II · 4:42
On a sparse graph the O(n^2) scan for the closest vertex wastes almost all its work, so we hand that job to a container. We run Dijkstra with a std::set (erase the old pair, insert the new one) and with a lazy std::priority_queue that pushes duplicates and skips stale entries, then measure both and show what forgetting the one-line stale check costs.