Download presentation
Presentation is loading. Please wait.
1
5 23 10 21 14 24 16 6 4 18 9 7 11 8 5 6 4 9 7 8 T, e T c(e) = 50 G = (V, E), c(e) Minimum Spanning Tree
2
5 23 10 21 14 24 16 6 4 18 9 7 11 8 Kruskal’s Algorithm: Add cheapest edge that does not create a cycle
3
4 5 23 10 21 14 24 16 6 18 9 7 11 8 Kruskal’s Algorithm: Add cheapest edge that does not create a cycle
4
4 5 23 10 21 14 24 16 6 18 9 7 11 8 Kruskal’s Algorithm: Add cheapest edge that does not create a cycle
5
6 4 5 23 10 21 14 24 16 18 9 7 11 8 Kruskal’s Algorithm: Add cheapest edge that does not create a cycle
6
7 6 4 5 23 10 21 14 24 16 18 9 11 8 Kruskal’s Algorithm: Add cheapest edge that does not create a cycle
7
8 7 6 4 5 23 10 21 14 24 16 18 9 11 Kruskal’s Algorithm: Add cheapest edge that does not create a cycle
8
9 8 7 6 4 5 23 10 21 14 24 16 18 11 Kruskal’s Algorithm: Add cheapest edge that does not create a cycle
9
9 8 7 6 4 5 23 10 21 14 24 16 18 11 Kruskal’s Algorithm: Add cheapest edge that does not create a cycle ?
10
9 8 7 6 4 5 23 10 21 14 24 16 18 11 Kruskal’s Algorithm: Add cheapest edge that does not create a cycle Ignore edges inside components
11
9 8 7 6 4 5 23 10 21 14 24 16 18 11 Kruskal’s Algorithm: Add cheapest edge that does not create a cycle Ignore edges inside components
12
11 9 8 7 6 4 5 23 10 21 14 24 16 18 Kruskal’s Algorithm: Add cheapest edge that does not create a cycle Ignore edges inside components
13
11 9 8 7 6 4 5 23 10 21 14 24 16 18 Kruskal’s Algorithm: Add cheapest edge that does not create a cycle Ignore edges inside components
15
5 23 10 21 14 24 16 6 4 18 9 7 11 8 Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node
16
Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 5 23 10 21 14 24 16 6 4 18 9 7 11 8
17
Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 5 23 10 21 14 24 16 6 4 18 9 7 11 8
18
Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 5 23 10 21 14 24 16 6 4 18 9 7 11 8
19
6 5 4 8 Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 23 10 21 14 24 16 18 9 7 11
20
8 5 4 Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 23 10 21 14 24 16 6 18 9 7 11 Can remove edges between tree nodes
21
11 6 5 4 8 Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 23 10 21 14 24 16 18 9 7
22
7 11 6 5 4 8 Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 23 10 21 14 24 16 18 9
23
9 7 11 6 5 4 8 Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 23 10 21 14 24 16 18
25
node-comp array node123456789 comp118451188 comp-size array comp123456789 size400110030 Lists of nodes 1 : 1, 2, 6, 7 2 : 3 : 4 : 4 5 : 5 6 : 7 : 8 : 8, 9, 3 9 : Components Data Structure Supporting Find and Merge (Union-Find)
26
Components Data Structure Supporting Find and Merge (Union-Find) node-comp array node123456789 comp123456789 comp-size array comp123456789 size111111111 Lists of nodes 1 : 1 2 : 2 3 : 3 4 : 4 5 : 5 6 : 6 7 : 7 8 : 8 9 : 9
27
Components Data Structure node-comp array node123456789 comp123456789 comp-size array comp123456789 size111111111 Lists of nodes 1 : 1 2 : 2 3 : 3 4 : 4 5 : 5 6 : 6 7 : 7 8 : 8 9 : 9 Merge(1,2)
28
Components Data Structure node-comp array node123456789 comp113456789 comp-size array comp123456789 size201111111 Lists of nodes 1 : 1, 2 2 : 3 : 3 4 : 4 5 : 5 6 : 6 7 : 7 8 : 8 9 : 9 Merge(1,2)
29
Components Data Structure node-comp array node123456789 comp118451188 comp-size array comp123456789 size400110030 Lists of nodes 1 : 1, 2, 6, 7 2 : 3 : 4 : 4 5 : 5 6 : 7 : 8 : 8, 9, 3 9 : Merge(1,8)
30
Components Data Structure node-comp array node123456789 comp118451188 comp-size array comp123456789 size400110030 Lists of nodes 1 : 1, 2, 6, 7 2 : 3 : 4 : 4 5 : 5 6 : 7 : 8 : 8, 9, 3 9 : Merge(1,8)
31
Components Data Structure node-comp array node123456789 comp118451118 comp-size array comp123456789 size400110030 Lists of nodes 1 : 1, 2, 6, 7 2 : 3 : 4 : 4 5 : 5 6 : 7 : 8 : 8, 9, 3 9 : Merge(1,8)
32
Components Data Structure node-comp array node123456789 comp118451111 comp-size array comp123456789 size400110030 Lists of nodes 1 : 1, 2, 6, 7 2 : 3 : 4 : 4 5 : 5 6 : 7 : 8 : 8, 9, 3 9 : Merge(1,8)
33
Components Data Structure node-comp array node123456789 comp111451111 comp-size array comp123456789 size400110030 Lists of nodes 1 : 1, 2, 6, 7 2 : 3 : 4 : 4 5 : 5 6 : 7 : 8 : 8, 9, 3 9 : Merge(1,8)
34
Components Data Structure node-comp array node123456789 comp111451111 comp-size array comp123456789 size400110030 Lists of nodes 1 : 1, 2, 6, 7, 8, 9, 3 2 : 3 : 4 : 4 5 : 5 6 : 7 : 8 : 9 : Merge(1,8)
36
Components Data Structure Pointer Version 1(1)2(1)6(1)3(1)4(1)5(1)8(1)9(1)7(1) Merge(1,2)
37
Components Data Structure Pointer Version 1(1) 2 6(1)3(1)4(1)5(1)8(1)9(1)7(1) Merge(1,2)
38
Components Data Structure Pointer Version 1(2) 2 6(1)3(1)4(1)5(1)8(1)9(1)7(1) Merge(3,4)
39
Components Data Structure Pointer Version 1(2) 2 6(1) 3 4 5(1)8(1)9(1)7(1) Merge(3,4)
40
Components Data Structure Pointer Version 1(1) 2 6(1)3(2) 4 5(1)8(1)9(1)7(1) Merge(1,3)
41
Components Data Structure Pointer Version 1(2) 2 6(1)3(2) 4 5(1)8(1)9(1)7(1) Merge(1,3)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.