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

## 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:

Greed is Good But gluttony is a deadly sin

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

Prim’s Algorithm

1 2 5 3 a dc b

1 2 3 a dc b Minimum Spanning Tree

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

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

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)

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)

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)

bc adf e 4 4 3 1 55 86 2 6

Kruskal’s Algorithm

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)

bc adf e 44 3 1 55 86 2 6

bc adf e 44 3 1 55 86 2 6

bc adf e 44 3 1 55 86 2 6

bc adf e 44 3 1 55 86 2 6

bc adf e 44 3 1 55 86 2 6

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