1 / 21

Greed is Good But gluttony is a deadly sin

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. a. b. 2. 5. 3. c. d. Minimum Spanning Tree. 1. a. b. 2. 3. c. d. 1. 3. 6. 4. 4. 5. 5. 2. 6. 8.

nansen
Download Presentation

Greed is Good But gluttony is a deadly sin

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Greed is GoodBut 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 a b 2 5 3 c d

  5. Minimum Spanning Tree 1 a b 2 3 c d

  6. 1 3 6 4 4 5 5 2 6 8 PQ: (a,b,3) ; (a,f,5) ; (a,e,6) b c a f d e

  7. 1 3 6 4 4 5 5 2 6 8 PQ: (b,c,1) ; (b,f,4) ; (a,f,5) ; (a,e,6) b c a f d e

  8. 1 3 6 4 4 5 5 2 6 8 PQ: (c,f,4) ; (b,f,4) ; (a,f,5) ; (a,e,6) ; (c,d,6) b c a f d e

  9. 6 4 4 5 5 2 6 8 PQ: (f,e,2) ; (b,f,4) ; (a,f,5) ; (f,d,5) ; (a,e,6) ; (c,d,6) 1 b c 3 a f d e

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

  11. 6 4 5 6 8 1 b c 3 4 5 a f d 2 e

  12. Kruskal’s Algorithm

  13. 1 3 6 4 4 5 5 2 6 8 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) b c a f d e

  14. 3 6 4 4 5 5 2 6 8 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) 1 b c a f d e

  15. 1 3 6 4 4 5 5 2 6 8 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) b c a f d e

  16. 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) 1 b c 3 6 4 4 5 5 a f d 2 6 8 e

  17. 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) 1 b c 3 6 4 4 5 5 a f d 2 6 8 e

  18. 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) 1 b c 3 6 4 4 5 5 a f d 2 6 8 e

  19. DONE!!DANKEITHAKN YOU! Nou kan jy aangaan met jou lewe…

More Related