Algorithm Design - Heinz Nixdorf Institut · –if the greedy algorithm stays ahead. Show that...

Post on 22-Jun-2020

2 views 0 download

transcript

Friedhelm Meyer auf der Heide 1

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

Welcome to the course

Algorithm Design

Summer Term 2011

Friedhelm Meyer auf der Heide

Lecture 4, 6.5.2011

Lecture today given by Ulf-Peter Schröder

Friedhelm Meyer auf der Heide 2

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity Today:

Chapter 3:

Greedy Algorithms

Friedhelm Meyer auf der Heide 3

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity The Greedy Paradigm

Friedhelm Meyer auf der Heide 4

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity Greedy is not always optimal

Friedhelm Meyer auf der Heide 5

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity Greedy is not always optimal

Friedhelm Meyer auf der Heide 6

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity …but sometimes

Friedhelm Meyer auf der Heide 7

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity …but sometimes

Fundamental Questions

• When did a Greedy Algorithm succeeds in

solving a nontrivial problem optimally?

• How to prove that a Greedy Algorithm

produces an optimal solution to a problem?

06.05.2011 8

06.05.2011 9

The Greedy Method • Greedy as Algorithmic technique can optimally solve an

optimization problem,

– if the greedy algorithm stays ahead. Show that after each step of the greedy algorithm, its solution is at least as good as any other algorithm’s or

– if we can find an exchange argument. Gradually transform any solution to the one found by the greedy algorithm without hurting its quality or

– if the problem has the greedy-choice property. Prove that a globally-optimal solution can always be found by a series of local improvements from a starting configuration or

– if we can define an adequate Matroid for the problem.

06.05.2011 10

Examples

• Activity Selection (or Intervall Scheduling) – Greedy stays ahead

• Scheduling to Minimize Lateness – Exchange Argument

• Theoretical Foundations of the Greedy Method – Matroid Theory

06.05.2011 11

Activity Selection

06.05.2011 12

06.05.2011 13

06.05.2011 14

06.05.2011 15

Time 0

A

C

F

B

D

G

E

1 2 3 4 5 6 7 8 9 10 11

H

0 1 2 3 4 5 6 7 8 9 10 11

0 1 2 3 4 5 6 7 8 9 10 11

B

Time 0

A

C

F

B

D

G

E

1 2 3 4 5 6 7 8 9 10 11

H

0 1 2 3 4 5 6 7 8 9 10 11

B C

Time 0

A

C

F

B

D

G

E

1 2 3 4 5 6 7 8 9 10 11

H

0 1 2 3 4 5 6 7 8 9 10 11

B A

Time 0

A

C

F

B

D

G

E

1 2 3 4 5 6 7 8 9 10 11

H

0 1 2 3 4 5 6 7 8 9 10 11

B E

Time 0

A

C

F

B

D

G

E

1 2 3 4 5 6 7 8 9 10 11

H

0 1 2 3 4 5 6 7 8 9 10 11

B E D

Time 0

A

C

F

B

D

G

E

1 2 3 4 5 6 7 8 9 10 11

H

0 1 2 3 4 5 6 7 8 9 10 11

B E F

Time 0

A

C

F

B

D

G

E

1 2 3 4 5 6 7 8 9 10 11

H

0 1 2 3 4 5 6 7 8 9 10 11

B E G

Time 0

A

C

F

B

D

G

E

1 2 3 4 5 6 7 8 9 10 11

H

0 1 2 3 4 5 6 7 8 9 10 11

B E H

Time 0

A

C

F

B

D

G

E

1 2 3 4 5 6 7 8 9 10 11

H

06.05.2011 25

06.05.2011 26

06.05.2011 27

If one measures the Greedy Algorithm’s progress in a step-by-step fashion, one sees that it does better than any other algorithm at each step (“greedy stays ahead”); it then follows that it produces an optimal solution!

What have we shown ?

06.05.2011 28

Examples

• Activity Selection (or Intervall Scheduling) – Greedy stays ahead

• Scheduling to Minimize Lateness – Exchange Argument

• Theoretical Foundations of the Greedy Method – Matroid Theory

06.05.2011 29

06.05.2011 30

06.05.2011 31

06.05.2011 32

06.05.2011 33

06.05.2011 34

06.05.2011 35

06.05.2011 36

06.05.2011 37

Any possible solution to the problem can be transformed (Exchange Property) into the solution found by the Greedy Algorithm without hurting its quality; it then follows that the greedy algorithm must have found a solution that is at least as good as any other solution!

What have we shown ?

Friedhelm Meyer auf der Heide 38

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

Friedhelm Meyer auf der Heide

Heinz Nixdorf Institute & Computer Science Department

University of Paderborn

Fürstenallee 11

33102 Paderborn, Germany

Tel.: +49 (0) 52 51/60 64 80

Fax: +49 (0) 52 51/62 64 82

E-Mail: fmadh@upb.de

http://www.upb.de/cs/ag-madh

Thank you for

your attention!