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

Sign in to watch this lesson
Algorithms - Graphs II · 5:23
To connect eight offices with the cheapest set of leased lines, we need a minimum spanning tree: no loops, exactly n - 1 lines. The cut property explains why the cheapest line across any split is safe, Kruskal's algorithm turns it into a procedure (sort by price, skip any line that closes a loop; total 31 on our graph), and a disjoint set union with union by size and path compression answers 'already connected?' in almost constant time, so the sort's O(m log m) dominates.