Kruskal's Runtime

  • Explain how to implement Kruskal's algorithm efficiently using a union-find structure to detect cycles. Identify the resulting time complexity.

How to get the next min-weight edge?

Keep edged in a (min-heap) priority queue.

How to check if adding edge (v-w) creates a cycle?

Use Union-Find to help in checking/preventing cycle

Exercise Complete the following table:

OperationFrequencyCost per operation
build PQ
extract min
union
connected
Solution
OperationFrequencyCost per operation
build PQ11O(M)\Omicron(M)
extract minO(M)\Omicron(M)O(lgM)\Omicron(\lg M)
unionO(N)\Omicron(N)O(lgN)\Omicron(\lg^* N)
connectedO(M)\Omicron(M)O(lgN)\Omicron(\lg^* N)