COMS 482: unofficial class blog


Lecture 3: Greedy Algorithms

Posted in Class Notes by Elliott Back on January 28th, 2005. [Del.icio.us]
  • The schedule is now online.
  • HW1 is due on Friday
  • If the bookstore is out of course packets, put in a request for one so that they’ll print more. Otherwise you might not get one.

(4.1 - 4.6) Greedy Algorithms:

  • Always choose a local optimum
  • Stable Marriage is an example of a greedy algorithm

Solving an algorithms problem:

  1. Give an algorithm
  2. Give a proof of correctness
  3. Analyze running time

Interval Scheduling:

Some suggestions for choosing the interval segments. Choose the:

  • First to finish
  • x Shortest one
  • x First left endpoint
  • x One with fewest conflicts

S = {segments}
A = {}
while S != {} do
    choose s in S with minimum right endpoint
    A = A U {s}
    delete all s’ in S that overlap with s
end

“The rth interval is at least as good as the rth interval in the optimal set”

A contains no overlapping intervals. Let {i1, … , ik} be the set of segments added to A, in order, and let {j1, … , jk} be the set of segments in O, the optimal solution. Since by our rule f(i1) < = f(j1), we see that we "stay ahead" of the optimal solution at each step by choosing the "shortest" possible segment. This allows us to assume that f(ir-1) < = f(jr-1). We know that f(jr-1) < = s(jr) because all the segments in S are compatible. With our inductive assumption, we can write f(ir-1) < = s(jr), thus jr has not been already selected or eliminated when we choose ir. Since the greedy algorithm chooses the interval with the smallest finish time, we pick one equal or smaller to jr: ir < = jr.

“A is an optimal solution”

By contradiction, if A isn’t optimal, then the optimal set O will have more requests. This would mean that (a) there must be m > k requests, and (b) O makes a k+1th request after both ik and jk end. This means that after deleting all requests that are incompatible with {i1, … , ik} the set of possible requests R still contains jk+1. But the greedy algorithm stops on request ik, and it only stops when R is empty–a contradiction!

This entry was posted on Friday, January 28th, 2005 at 11:29 am and is tagged with , , , , , , , , , , , , , , , , , , . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback.

One Response to 'Lecture 3: Greedy Algorithms'

  1. […] ts until done. Proof proceeds by “stays ahead” argument. See lecture 3 for a proof of optimality. Interval P […]

Leave a Reply

I'll protect you: the intense, widespread, great, and extensive Wordpress Hash-cash?

Please take time to enjoy the archives: May 2005 (1) April 2005 (11) March 2005 (11) February 2005 (15) January 2005 (7)

Fresh, related resources:

Supplied by Google Blog Search
  • mmmhmm.
    So, what if you were taking a test, or were listening to a lecture, or were at the movies, when... you get an ACHING, HORRENDOUS, and VIOLENT urge to use the bathroom? Pee or poo, it doesn't matter. You can't leave wherever you are, ...
  • I HEART Boston (Part 2 of 3 today)
    Of course I didn't lecture either of them (didn't want to cause a ruckus) so as soon as one of them took their arm off the armrest I claimed it for myself for the rest of the flight. Sometimes you just gotta be greedy and take the ...
  • Knapsack problem
    1 Definition; 2 Dynamic programming solution; 3 Greedy approximation algorithm; 4 See also; 5 References; 6 Further reading; 7 External links. //. Definition. In the following, we have n kinds of items, 1 through n. ...
  • CSE Syllabus 3rd year
    3 hours lecture and 1 hour tutorial per week. Module I (13 hours). Problems and algorithms - classification of problems - decision - search - optimization and enumeration problems - review of unsolvability - rice theorem - fixed point ...
  • Lecture Outline
    This is a lecture outline for the class. When appropriate, I will reference chapters and sections from the textbook (KT 3 refers to Chapter 3). This outline is subject to minor changes, but I expect that the top level topics will be ...