{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture19-greedy-minspanningtree

# Lecture19-greedy-minspanningtree - This work is licensed...

This preview shows pages 1–8. Sign up to view the full content.

CS 312: Algorithm Analysis Lecture #19: Greedy Algorithms and Minimal Spanning Trees This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. Slides by: Eric Ringger, with contributions from Mike Jones, Eric Mercer, Sean Warnick and figures from Dasgupta et al.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Announcements § HW #12 § Due now § Monday: President’s Day holiday § Meet Tuesday instead § Mid-Term Exam § Review: next Wednesday § Exam: next Thu, Fri, Sat in Testing Center § 3 hours max – beware Saturday closing time
Objectives § Define a greedy algorithm § Solve the coins problem with a greedy algorithm § Define the Minimal Spanning Tree (MST) problem § Understand Kruskal’s Algorithm § Prove correctness of Kruskal’s Algorithm

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Coins Problem § Given : unbounded supply of coins of various denominations. § Given : a number c § Find : minimal number of coins that add up to c . Learning Activity § Need a volunteer to solve the problem § Explain why you did what you did at every step § Everyone: write an algorithm to solve this problem (on
Greedy Algorithms: Main Idea § Optimize some quantity of interest § Build up a solution piece by piece § Always choose the next piece that offers the most obvious and immediate benefit § Without violating given constraints

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Generalizing Greedy Algs. function greedy (C) Input: set of candidates C Output: solution S (a set), optimal quantity S   while (C !=  & ! solution (S)) x  select (C) C  C \ {x} if feasible (S{x}) then S  S  {x} if solution (S) then return S else return 
function greedy (C) Input: set of candidates C Output: solution S (a set), optimal quantity S   while (C !=  & ! solution (S)) x  select (C) C  C \ {x} if feasible (S{x}) then S  S  {x} if solution (S) then return S else return  Generalizing Greedy Algs.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern