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

Sign in to watch this lesson
Algorithms - Graphs II · 4:28
Prim's algorithm grows a single tree outward from one vertex, always adding the shortest edge that leaves it; on twelve desks of a floor plan, the dashed 'cheapest link' of every outside desk swings and shortens as the tree approaches, for a total of about 50.14 m. Its key is the edge's length, not the route's (mixing it up with Dijkstra builds a shortest-path tree), and it comes in a dense O(n^2) version that never stores the edges and a heap version for sparse graphs, measured against Kruskal on this Mac.