minimum spanning tree neil tang 3/25/2010
DESCRIPTION
Minimum Spanning Tree Neil Tang 3/25/2010. Class Overview. The minimum spanning tree problem Applications Prim’s algorithm Kruskal’s algorithm. Minimum Spanning Tree Problem. The cost of a tree: The sum of the weights of all links on the tree. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Minimum Spanning Tree Neil Tang 3/25/2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/5681313b550346895d97b19e/html5/thumbnails/1.jpg)
CS223 Advanced Data Structures and Algorithms 1
Minimum Spanning Tree Minimum Spanning Tree
Neil TangNeil Tang3/25/20103/25/2010
![Page 2: Minimum Spanning Tree Neil Tang 3/25/2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/5681313b550346895d97b19e/html5/thumbnails/2.jpg)
CS223 Advanced Data Structures and Algorithms 2
Class OverviewClass Overview
The minimum spanning tree problem
Applications
Prim’s algorithm
Kruskal’s algorithm
![Page 3: Minimum Spanning Tree Neil Tang 3/25/2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/5681313b550346895d97b19e/html5/thumbnails/3.jpg)
CS223 Advanced Data Structures and Algorithms 3
Minimum Spanning Tree ProblemMinimum Spanning Tree Problem
The cost of a tree: The sum of the weights of all links on the tree.
The Minimum Spanning Tree (MST) problem: Given a weighted undirected graph G, find a minimum cost tree connecting all the vertices on the graph.
![Page 4: Minimum Spanning Tree Neil Tang 3/25/2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/5681313b550346895d97b19e/html5/thumbnails/4.jpg)
CS223 Advanced Data Structures and Algorithms 4
Minimum Spanning Tree ProblemMinimum Spanning Tree Problem
![Page 5: Minimum Spanning Tree Neil Tang 3/25/2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/5681313b550346895d97b19e/html5/thumbnails/5.jpg)
CS223 Advanced Data Structures and Algorithms 5
ApplicationsApplications
Broadcasting problem in computer networks: Find the minimum cost route to send packages from a source node to all the other nodes in the network.
Multicasting problem in computer networks: Find the minimum cost route to send packages from a source node to a subset of other nodes in the network.
![Page 6: Minimum Spanning Tree Neil Tang 3/25/2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/5681313b550346895d97b19e/html5/thumbnails/6.jpg)
CS223 Advanced Data Structures and Algorithms 6
Prim’s AlgorithmPrim’s Algorithm
![Page 7: Minimum Spanning Tree Neil Tang 3/25/2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/5681313b550346895d97b19e/html5/thumbnails/7.jpg)
CS223 Advanced Data Structures and Algorithms 7
Prim’s AlgorithmPrim’s Algorithm
![Page 8: Minimum Spanning Tree Neil Tang 3/25/2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/5681313b550346895d97b19e/html5/thumbnails/8.jpg)
CS223 Advanced Data Structures and Algorithms 8
Prim’s AlgorithmPrim’s Algorithm
![Page 9: Minimum Spanning Tree Neil Tang 3/25/2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/5681313b550346895d97b19e/html5/thumbnails/9.jpg)
CS223 Advanced Data Structures and Algorithms 9
Prim’s AlgorithmPrim’s Algorithm
Arbitrarily pick a vertex to start with.
Relaxation: dw=min(dw, cwv), where v is the newly marked vertex, w is one of its unmarked neighbors, cwv is the weight of edge (w,v) and dw indicates the current distance between w and one of the marked vertices.
![Page 10: Minimum Spanning Tree Neil Tang 3/25/2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/5681313b550346895d97b19e/html5/thumbnails/10.jpg)
CS223 Advanced Data Structures and Algorithms 10
Dijkstra’s AlgorithmDijkstra’s Algorithm
Need to be changed:
![Page 11: Minimum Spanning Tree Neil Tang 3/25/2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/5681313b550346895d97b19e/html5/thumbnails/11.jpg)
CS223 Advanced Data Structures and Algorithms 11
Prim’s AlgorithmPrim’s Algorithm
Trivial: O(|V|2 + |E|) = O(|V|2)
Heap: deleteMin |V| times + decreaseKey |E| times
O(|V|log|V| + |E|log|V|) = O (|E|log|V|)
![Page 12: Minimum Spanning Tree Neil Tang 3/25/2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/5681313b550346895d97b19e/html5/thumbnails/12.jpg)
CS223 Advanced Data Structures and Algorithms 12
Kruskal’s AlgorithmKruskal’s Algorithm
![Page 13: Minimum Spanning Tree Neil Tang 3/25/2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/5681313b550346895d97b19e/html5/thumbnails/13.jpg)
CS223 Advanced Data Structures and Algorithms 13
Kruskal’s AlgorithmKruskal’s Algorithm
![Page 14: Minimum Spanning Tree Neil Tang 3/25/2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/5681313b550346895d97b19e/html5/thumbnails/14.jpg)
CS223 Advanced Data Structures and Algorithms 14
Kruskal’s AlgorithmKruskal’s Algorithm
O(|E|)
O(|E|log|E|)O(|E|log|V|)
O(|E|)
Time complexity: O(|E|log|E|) = O (|E|log|V|)