1 / 8

CSC 172 DATA STRUCTURES

CSC 172 DATA STRUCTURES. Kruskal’s Algorithm. An example of a “greedy” algorithm “do what seems best at the moment” Use the merge/find MWST algorithm on the edges in ascending order O(m log m) Since m <= n2, log m <= 2 log n, so O(m log n) time. Find the MWST. A. 10. 1. F. B. 8. 7.

anisa
Download Presentation

CSC 172 DATA STRUCTURES

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. CSC 172 DATA STRUCTURES

  2. Kruskal’s Algorithm An example of a “greedy” algorithm “do what seems best at the moment” Use the merge/find MWST algorithm on the edges in ascending order O(m log m) Since m <= n2, log m <= 2 log n, so O(m log n) time

  3. Find the MWST A 10 1 F B 8 7 9 5 2 6 11 12 E C 3 4 D

  4. Find the MWST 1 + 2 + 3 + 4 + 5 == 15 A 10 1 F B 8 7 9 5 2 6 11 12 E C 3 4 D

  5. GREED IS NOT ALWAYS GOOD

  6. Find the minimum cycle A 10 1 F B 8 7 9 5 2 6 11 12 E C 3 4 D

  7. Find the minimum cycle 1 + 2 + 3 + 4 + 5 +10 == 25 A 10 1 F B 8 7 9 5 2 6 11 12 E C 3 4 D

  8. Find the minimum cycle 1 + 2 + 3 + 6 + 5 + 7 = 24 A 10 1 F B 8 7 9 5 2 6 11 12 E C 3 4 D

More Related