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

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