algorithm design - heinz nixdorf institut · friedhelm meyer auf der heide 5 heinz nixdorf...

46
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 6, 20.5.2011

Upload: others

Post on 22-Jun-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

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 6, 20.5.2011

Page 2: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Friedhelm Meyer auf der Heide 2

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity Topics

- Divide & conquer

- Dynamic programming

- Greedy Algorithms

- Approximation Algorithms

- Randomized Algorithms

- Online Algorithms

Page 3: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Friedhelm Meyer auf der Heide 3

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

For which problems are Greedy-Algorithms

optimal?

Consider a finite set E and a system U of subsets of E. (E,U) is called a

subset-system, if the following holds:

(i) ? 2 U

(ii) For each B 2 U, also each subset of B is in U.

B2 U is called maximal, if no proper superset of B is in U.

The Optimization problem corresponding to (E,U) is :

Given a weight function w:E Q+ ,compute a maximal set B 2 U with

maximizes w(B) = §e2 B w(e).

(Minimization problems are described analogously.)

Page 4: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Friedhelm Meyer auf der Heide 4

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

Subset-Systems and the

Canonical Greedy-Algorithm

Canonical Greedy ((E,U))

(1) Sort E such that w(e1) ¸ … ¸ w(en).

(2) B ?.

(3) For k=1 to n

if B [ {ek} 2 U then B B [ {ek}

(4) Return B

Page 5: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Friedhelm Meyer auf der Heide 5

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity Greedy-Algorithms und Matroids

A system of subsets (E,U) is a matroid, if in addition, the following

exchange property holds:

(iii) For all A,B 2 U with |A|<|B|, there is x2 B-A such that A[{x} 2 U.

Remark: All maximal sets of a matroid have the same size. (homework)

Theorem: Consider a system of subsets (E,U). Canonical Greedy is optimal

for (E,U) for every weight function w, if and only if (E,U) is a matroid.

Page 6: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Friedhelm Meyer auf der Heide 6

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity Matroids and the canonical Greedy Algorithm

Theorem: Consider a system of subsets (E,U). Canonical Greedy is optimal

for (E,U) for every weight function w, if and only if (E,U) is a matroid.

Proof:

“(”: Consider a matroid (E,U) and a weight function w.

Let w(e1)¸ …¸ w(en).

- Consider an optimal solution T’={ei1, …, eik

}.

- Assume the solution T={ej1, …, ejk

} found by Canonical Greedy were not

optimal, i.e. w(T’)> w(T).

- Then there is an index p with w(eip) > w(ejp

). Let p be minimal with this

property. Note that ip < jp, because the items are sorted w.r.t weight.

- Apply the exchange property to A = {ej1, …,ejp-1

} and B ={ei1, …, eip

} :

As |A| < |B|, there is eiq 2 B-A with A [ {eiq

} 2 U.

- As w(eiq ) ¸ w(eip

) > w(ejp), Canonical Greedy would have chosen eiq

before

ejp , a contradiction.

Page 7: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Friedhelm Meyer auf der Heide 7

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity Matroids and the canonical Greedy Algorithm

Theorem: Consider a system of subsets (E,U). Canonical Greedy is optimal for (E,U) for every weight function w, if and only if (E,U) is a matroid.

Proof:

“)”: Assume that, for some A,B 2 U with |A|<|B|, it holds that A[{e} is not in U, for every e2B-A.

Let |B|=r and consider the weight function w with

- w(e) = r+1 for e2A

- w(e) = r for e2B-A

- w(e) = 0 else

Then, Canonical Greedy would select a solution T with T µ A and T Å (B-A) =?.

As w(T)=|A|(r+1) · (r-1)(r+1)· r2 -1, T is not optimal, because B is a solution with larger weight |B|r = r2.

Page 8: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Friedhelm Meyer auf der Heide 8

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity Topics

- Divide & conquer

- Dynamic programming

- Greedy Algorithms

- Approximation Algorithms

- Randomized Algorithms

- Online Algorithms

Page 9: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 9

Page 10: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 10

Approximation Algorithms

• Greedy Techniques – Load-Balancing Problem

– Center Selection Problem

• Pricing Method – Vertex Cover Problem

• Linear Programming and Rounding – Vertex Cover Problem

– Generalized Load-Balancing Problem

• Polynomial Time Approximation Scheme – Knapsack Problem

Page 11: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 11

Page 12: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 12

Page 13: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Load Balancing: List Scheduling

A D

F

B C E

Machine 3

Machine 2

Time 0

Machine 1

I H J

G

Page 14: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Machine 3

Machine 2

Machine 1

Load Balancing: List Scheduling

A

D

F

B C E

Time 0

I H J

G

Page 15: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Machine 3

Machine 2

Machine 1

Load Balancing: List Scheduling

A

D

F

B

C E

Time 0

I H J

G

Page 16: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Machine 3

Machine 2

Machine 1

Load Balancing: List Scheduling

A

D

F

B

C

E

Time 0

I H J

G

Page 17: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Machine 3

Machine 2

Machine 1

Load Balancing: List Scheduling

A

F

B

C

E

Time 0

I H J

G

D

Page 18: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Machine 3

Machine 2

Machine 1

Load Balancing: List Scheduling

A

F

B

C

E

Time 0

I H J

G

D

Page 19: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

G

Machine 3

Machine 2

Machine 1

Load Balancing: List Scheduling

A

F

B

C

E

Time 0

I H J

D

Page 20: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Machine 3

Machine 2

Machine 1

Load Balancing: List Scheduling

A

F

B

C

E

Time 0

I H J

G D

Page 21: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Machine 3

Machine 2

Machine 1

Load Balancing: List Scheduling

A

F

B

C

E

Time 0

I

H

J

G D

Page 22: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Machine 3

Machine 2

Machine 1

Load Balancing: List Scheduling

A

F

B

C

G

E

Time 0

I H

J

G D

Page 23: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Machine 3

Machine 2

Machine 1

Load Balancing: List Scheduling

A

F

B

C

G

E

Time 0

I H

J

D

Page 24: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Machine 3

Machine 2

Machine 1

Load Balancing: List Scheduling

A

D

F

B

C

G

E

0

I H

J

Machine 3

Machine 2

Machine 1

A

D

F

B C

G

E

0

I

H

J

Optimal Schedule

List schedule

Page 25: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 25

1.

2.

Page 26: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 26

Page 27: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 27

Page 28: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 28

Page 29: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 29

Page 30: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 30

Page 31: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 31

Page 32: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 32

Page 33: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 33

Approximation Algorithms

• Greedy Techniques – Load-Balancing Problem

– Center Selection Problem

• Pricing Method – Vertex Cover Problem

• Linear Programming and Rounding – Vertex Cover Problem

– Generalized Load-Balancing Problem

• Polynomial Time Approximation Scheme – Knapsack Problem

Page 34: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 34

Page 35: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 35

Page 36: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 36

Page 37: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 37

Page 38: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 38

Page 39: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 39

Page 40: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 40

Approximation Algorithms

• Greedy Techniques – Load-Balancing Problem

– Center Selection Problem

• Pricing Method – Vertex Cover Problem

• Linear Programming and Rounding – Vertex Cover Problem

– Generalized Load-Balancing Problem

• Polynomial Time Approximation Scheme – Knapsack Problem

Page 41: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 41

Page 42: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 42

Page 43: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 43

Page 44: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 44

Page 45: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

23.05.2011 45

Page 46: Algorithm Design - Heinz Nixdorf Institut · Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithms und Matroids

Friedhelm Meyer auf der Heide 46

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: [email protected]

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

Thank you for

your attention!