































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
































































Mahesh Viswanathan [email protected] 3232 Siebel Center University of Illinois, Urbana-Champaign
Spring 2007
Data Structures
Data Structures Implementing Kruskal’s AlgorithmUnion-Find Data Structure
E is the set of all edges in G S = { 1 } T is empty (* T will store edges of a MST *) while S =/= V pick e = (v,w) in E such that v ∈ S and w ∈ V - S e has minimum cost T = T U e S = S U w return the set T Analysis Number of iterations = O(n), where n is number of vertices
Data Structures Implementing Kruskal’s AlgorithmUnion-Find Data Structure
E is the set of all edges in G S = { 1 } T is empty (* T will store edges of a MST *) while S =/= V pick e = (v,w) in E such that v ∈ S and w ∈ V - S e has minimum cost T = T U e S = S U w return the set T Analysis Number of iterations = O(n), where n is number of vertices Picking e is O(m) where m is the number of edges
Data Structures Implementing Kruskal’s AlgorithmUnion-Find Data Structure
E is the set of all edges in G S = { 1 } T is empty (* T will store edges of a MST *) for v 6 ∈ S, a(v) = minw ∈S c(w,v) for v 6 ∈ S, e(v) = w such that w ∈ S and c(w,v) is minimum while S =/= V pick v with minimum a(v) T = T U (e(v),v) S = S U v update arrays a and e return the set T
Data Structures Implementing Kruskal’s AlgorithmUnion-Find Data Structure
E is the set of all edges in G S = { 1 } T is empty (* T will store edges of a MST *) for v 6 ∈ S, a(v) = minw ∈S c(w,v) for v 6 ∈ S, e(v) = w such that w ∈ S and c(w,v) is minimum while S =/= V pick v with minimum a(v) T = T U (e(v),v) S = S U v update arrays a and e return the set T
Data Structures Implementing Kruskal’s AlgorithmUnion-Find Data Structure
Data structure to store a set S of n elements where each element v ∈ S has an associated key k(v ) such that the following operations extractMin: Remove v ∈ S with smallest key add: Add an element to set S delete: Remove element from S changeKey: Change the key associated with an element can be performed in O(log n) time each.
Data Structures Implementing Kruskal’s AlgorithmUnion-Find Data Structure
Data structure to store a set S of n elements where each element v ∈ S has an associated key k(v ) such that the following operations extractMin: Remove v ∈ S with smallest key add: Add an element to set S delete: Remove element from S changeKey: Change the key associated with an element can be performed in O(log n) time each.
Data Structures Implementing Kruskal’s AlgorithmUnion-Find Data Structure
E is the set of all edges in G S = { 1 } T is empty (* T will store edges of a MST *) for v 6 ∈ S, a(v) = minw ∈S c(w,v) for v 6 ∈ S, e(v) = w such that w ∈ S and c(w,v) is minimum while S =/= V pick v with minimum a(v) T = T U (e(v),v) S = S U v update arrays a and e return the set T Maintain vertices in V \ S in a priority queue with key a(v ) Requires O(n) extractMin operations
Data Structures Implementing Kruskal’s AlgorithmUnion-Find Data Structure
E is the set of all edges in G S = { 1 } T is empty (* T will store edges of a MST *) for v 6 ∈ S, a(v) = minw ∈S c(w,v) for v 6 ∈ S, e(v) = w such that w ∈ S and c(w,v) is minimum while S =/= V pick v with minimum a(v) T = T U (e(v),v) S = S U v update arrays a and e return the set T Maintain vertices in V \ S in a priority queue with key a(v ) Requires O(n) extractMin operations Requires O(m) changeKey operations
Data Structures Implementing Kruskal’s AlgorithmUnion-Find Data Structure
Using Lists Store elements in a list, and have pointer to element with smallest key
Data Structures Implementing Kruskal’s AlgorithmUnion-Find Data Structure
Using Lists Store elements in a list, and have pointer to element with smallest key
Data Structures Implementing Kruskal’s AlgorithmUnion-Find Data Structure
Using Lists Store elements in a list, and have pointer to element with smallest key
Data Structures Implementing Kruskal’s AlgorithmUnion-Find Data Structure
Using Lists Store elements in a list, and have pointer to element with smallest key