Presentation is loading. Please wait.

Presentation is loading. Please wait.

Prim’s Minimum Spanning Tree Algorithm Neil Tang 4/1/2008

Similar presentations


Presentation on theme: "Prim’s Minimum Spanning Tree Algorithm Neil Tang 4/1/2008"— Presentation transcript:

1 Prim’s Minimum Spanning Tree Algorithm Neil Tang 4/1/2008
CS223 Advanced Data Structures and Algorithms

2 CS223 Advanced Data Structures and Algorithms
Class Overview The minimum spanning tree problem An application Prim’s algorithm Implementation and time complexity CS223 Advanced Data Structures and Algorithms

3 Minimum 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 CS223 Advanced Data Structures and Algorithms

4 Minimum Spanning Tree Problem
CS223 Advanced Data Structures and Algorithms

5 CS223 Advanced Data Structures and Algorithms
An Application Broadcasting problem in Computer Networks: Find the minimum cost route to send a package from a source node to all the other nodes in the network. CS223 Advanced Data Structures and Algorithms

6 CS223 Advanced Data Structures and Algorithms
Prim’s Algorithm CS223 Advanced Data Structures and Algorithms

7 CS223 Advanced Data Structures and Algorithms
Prim’s Algorithm CS223 Advanced Data Structures and Algorithms

8 CS223 Advanced Data Structures and Algorithms
Prim’s Algorithm CS223 Advanced Data Structures and Algorithms

9 Implementation and Time Complexities
Difference between Prim and Dijkstra: 1) Arbitrarily pick a node to start with; 2) Relaxation dw=min(dw, cw,v) 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|) CS223 Advanced Data Structures and Algorithms


Download ppt "Prim’s Minimum Spanning Tree Algorithm Neil Tang 4/1/2008"

Similar presentations


Ads by Google