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 1 2 5 3 a dc b

5 1 2 3 a dc b Minimum Spanning Tree

6 bc adf e 44 3 1 55 86 2 6 PQ: (a,b,3) ; (a,f,5) ; (a,e,6)

7 bc adf e 44 3 1 55 86 2 6 PQ: (b,c,1) ; (b,f,4) ; (a,f,5) ; (a,e,6)

8 bc adf e 44 3 1 55 86 2 6 PQ: (c,f,4) ; (b,f,4) ; (a,f,5) ; (a,e,6) ; (c,d,6)

9 bc adf e 44 3 1 55 86 2 6 PQ: (f,e,2) ; (b,f,4) ; (a,f,5) ; (f,d,5) ; (a,e,6) ; (c,d,6)

10 bc adf e 4 4 3 1 55 86 2 6 PQ: (b,f,4) ; (a,f,5) ; (f,d,5) ; (a,e,6) ; (c,d,6) ; (e,d,8)

11 bc adf e 4 4 3 1 55 86 2 6

12

13

14 Kruskal’s Algorithm

15 bc adf e 44 3 1 55 86 2 6 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 44 3 1 55 86 2 6

17 bc adf e 44 3 1 55 86 2 6

18 bc adf e 44 3 1 55 86 2 6

19 bc adf e 44 3 1 55 86 2 6

20 bc adf e 44 3 1 55 86 2 6

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