Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 23.

Similar presentations


Presentation on theme: "Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 23."— Presentation transcript:

1 Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 23

2 2 Minimum Spanning Trees In the chip design, it is often necessary to make the pins of several components electrically equivalent by wiring them together. To interconnect a set of n pins, we can use an arrangement of n-1 wires, each connecting two pins. Objective is to use the least amout of wire. Model: A connected, undirected graph G=(V, E), where V is the set of pins, and E is the the set of possible interconnections. For each edge(u,v), a weight w(u,v) is assigned. The problem is to find an acyclic graph T (a subset of E) that connects all the vertices and the total weight below is minimized:

3 3 Example The airline connections between seven cities and three posible sets of connections a c b d ef g a c b d ef g a c b d ef g a c b d ef g

4 4 Minimum Spanning Trees… T is acyclic therefore a tree. There are two well-known algorithm’s to find T  Prim’s algorithm  Kruscal’s algorithm O(E lg V) At each step of these algorithms, one of the several possible choices must be made. These are good examples of “GREEDY” algorithms. mak GREEDY strategy advocates making the choice that is best “at the moment”. Hence, does not guarantee a globally optimal solution. An example is given next.

5 5 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

6 6 Kruscal Algorithm Tree=NIL E sorted by weight For (i=1; i<=|E| and |Tree|<|V|-1;i++)  If e i from E does not form a cycle with edges in Tree then Add e i to Tree Complexity O(|E| lg|E|)

7 7 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. a c b d ef g Tracing… 6 5 9 13 12 8 3 16 15 f g a c f g a c b f g a c b d (a) (c) (d) (b) 8

8 8 Tracing… (e) f g a c b d e f g a c b d e (f)


Download ppt "Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 23."

Similar presentations


Ads by Google