Download presentation

Presentation is loading. Please wait.

Published byShanon Neal Modified over 3 years ago

1
Prim’s Algorithm A Proof

2
Suppose we have a tree T that is the minimal spanning tree for a graph. Let P be the spanning tree from Prim’s alg. and Then there is an arc, a, in P that is not in T. If arc a connects node x to node y, then there is a path within the tree of T that also connects x to y: x y P T

3
Case 1: The weight of P is smaller than one of the edges on the path from the tree T Then we remove the edge with highest weight from T and replace it with the edge from P. This gives a smaller spanning tree than T – and contradicts the fact that T is the minimal spanning tree. x y P T

4
Case 2: The weight of P is greater than the weight of all the edges in the path from T. Then consider the step – in Prim’s algorithm- when we add edge P. P is the shortest edge remaining which can be added to the graph. But we would add xs before P (or st or tu or uy – whichever is still available to add. So we never add P – a contradiction! x P T y s t u

5
Depth-first search Algorithm DF(G,n) –Start with a given node, n. For all arcs a connected to n Do –DF(G\{n}, a) End - Do

6
Depth-first example A B C D E F G H I J K

7
A B C D E F G H I J K

8
A B C D E F G H I J K

9
A B C D E F G H I J K

10
A B C D E F G H I J K

11
A B C D E F G H I J K Continue: ABEDCHIJK (BACKTRACK to D) GF

12
Depth-first example-from K A B C D E F G H I J K

13
Breadth-First Algorithm BF(G,n) –Start with a given node, n. For all arcs a connected to n Do –Add nodes at end of each vertex. For all arcs a connected to n Do - BF(G\{arcs}, a)

14
Breadth-first example A B C D E F G H I J K

15
Add arcs connected to a A B C D E F G H I J K ABCDE

16
Add arcs connected to b A B C D E F G H I J K ABCDEF

18
Prim’s Algorithm A Proof

19
Suppose we have a tree T that is the minimal spanning tree for a graph. Let P be the spanning tree from Prim’s alg. and Then there is an arc, a, in P that is not in T. If arc a connects node x to node y, then there is a path within the tree of T that also connects x to y: x y P T

20
Case 1: The weight of P is smaller than one of the edges on the path from the tree T Then we remove the edge with highest weight from T and replace it with the edge from P. This gives a smaller spanning tree than T – and contradicts the fact that T is the minimal spanning tree. x y P T

21
Case 2: The weight of P is greater than the weight of all the edges in the path from T. Then consider the step – in Prim’s algorithm- when we add edge P. P is the shortest edge remaining which can be added to the graph. But we would add xs before P (or st or tu or uy – whichever is still available to add. So we never add P – a contradiction! x P T y s t u

22
Depth-first search Algorithm DF(G,n) –Start with a given node, n. For all arcs a connected to n Do –DF(G\{n}, a) End - Do

23
Depth-first example A B C D E F G H I J K

24
A B C D E F G H I J K

25
A B C D E F G H I J K

26
A B C D E F G H I J K

27
A B C D E F G H I J K

28
A B C D E F G H I J K Continue: ABEDCHIJK (BACKTRACK to D) GF

29
Depth-first example-from K A B C D E F G H I J K

30
Breadth-First Algorithm BF(G,n) –Start with a given node, n. For all arcs a connected to n Do –Add nodes at end of each vertex. For all arcs a connected to n Do - BF(G\{arcs}, a)

31
Breadth-first example A B C D E F G H I J K

32
Add arcs connected to a A B C D E F G H I J K ABCDE

33
Add arcs connected to b A B C D E F G H I J K ABCDEF

34
Continue: A B C D E F G H I J K ABCDEFHGJIK

35
Do breadth-first from D A B C D E F G H I J K

36
Be able to: Do depth first search and list nodes Do breadth-first search and list nodes Do either search and give the search tree.

37
Boolean Algebras Named after mathematician George Boole Created Boolean-algebras around 1850 He saw a connection between logic and certain algebraic properties He turned logic into algebra. Used in computers about 100 years after its invention – pure mathematics becomes applied mathematics.

38
Definition – Boolean Algebra A Boolean algebra is a set B, with two binary operations, + and x, a unary operator ‘ and in which there are special elements 0 and 1 such that x+y=y+xx y = y x (x+y)+z=x+(y+z) (x y) z = x (y z) x+(y z) = (x+y) x (x + z)x (y+z)=xy+xz x+0 = xx 1 = 1 x + x’= 1x x’ = 0

39
Examples 1. Sets with union (+), intersection (x) and set complement. What are 0 and 1? 2. Logic statements with or(+) and (x) and not(‘). Again, what are zero and one? 3. B={0,1} with usual multiplication and addition, except with 1+1 = 0. What is complement?

40
Check that every Boolean algebra has the idempotent property Show x+x=x. Proof (x+x)=(x+x) x 1 = (x+x) (x+x’) = x + x x’ (dist prop) X + 0 = x. Look at each example in terms of the idempotent property.

Similar presentations

OK

Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.

Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

By appt only movie channels Ppt on direct and online marketing Ppt on child labour in nepal Ppt on pre-ignition piston Ppt on c-programming basics Ppt on teamviewer 7 Ppt on asymptotic notation of algorithms examples Ppt on mohandas karamchand gandhi about Ppt on applied operations research va Well made play ppt on dvd