Lecture19-greedy-minspanningtree

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

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

View Full Document Right Arrow Icon
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.
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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
Background image of page 5

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

View Full DocumentRight Arrow Icon
Generalizing Greedy Algs. function greedy (C) Input: set of candidates C Output: solution S (a set), optimal quantity S   while solution (S)) x  select (C) C  C \ {x} if feasible (S{x}) then S  S  {x} if solution (S) then return S else return 
Background image of page 6
greedy (C) Input: set of candidates C Output: solution S (a set), optimal quantity S   while 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. Greedy takes a set C
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 35

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

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online