Presentation is loading. Please wait.

Presentation is loading. Please wait.

Greed is Good But gluttony is a deadly sin. What are greedy algorithms? Why they are useful Dangers of using greedy algorithms.

Similar presentations


Presentation on theme: "Greed is Good But gluttony is a deadly sin. What are greedy algorithms? Why they are useful Dangers of using greedy algorithms."— Presentation transcript:

1 Greed is Good But gluttony is a deadly sin

2 What are greedy algorithms? Why they are useful Dangers of using greedy algorithms

3 Prim’s Algorithm

4 a dc b

5 1 2 3 a dc b Minimum Spanning Tree

6 bc adf e PQ: (a,b,3) ; (a,f,5) ; (a,e,6)

7 bc adf e PQ: (b,c,1) ; (b,f,4) ; (a,f,5) ; (a,e,6)

8 bc adf e PQ: (c,f,4) ; (b,f,4) ; (a,f,5) ; (a,e,6) ; (c,d,6)

9 bc adf e PQ: (f,e,2) ; (b,f,4) ; (a,f,5) ; (f,d,5) ; (a,e,6) ; (c,d,6)

10 bc adf e PQ: (b,f,4) ; (a,f,5) ; (f,d,5) ; (a,e,6) ; (c,d,6) ; (e,d,8)

11 bc adf e

12

13

14 Kruskal’s Algorithm

15 bc adf e Sorted list: (b,c,1) ; (e,f,2) ; (a,b,3) ; (c,f,4) ; (b,f,4) ; (a,f,5) ; (d,f,5) ; (a,e,6) ; (c,d,6) ; (d,e,8)

16 bc adf e

17 bc adf e

18 bc adf e

19 bc adf e

20 bc adf e

21 DONE!! DANKEI THAKN YOU! Nou kan jy aangaan met jou lewe…


Download ppt "Greed is Good But gluttony is a deadly sin. What are greedy algorithms? Why they are useful Dangers of using greedy algorithms."

Similar presentations


Ads by Google