advanced algorithm design and analysis student: gertruda grolinger supervisor: prof. jeff edmonds...

27
Advanced Algorithm Advanced Algorithm Design and Analysis Design and Analysis Student: Student: Gertruda Gertruda Grolinger Grolinger Supervisor: Supervisor: Prof. Jeff Prof. Jeff Edmonds Edmonds CSE 4080 CSE 4080 Computer Science Project Computer Science Project

Upload: priscilla-mathews

Post on 23-Dec-2015

231 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Advanced Algorithm Advanced Algorithm Design and AnalysisDesign and Analysis

Student: Student: Gertruda Gertruda GrolingerGrolinger

Supervisor: Supervisor: Prof. Jeff Prof. Jeff EdmondsEdmonds

CSE 4080 CSE 4080 Computer Science ProjectComputer Science Project

Page 2: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Linear Programming: “What to put in a hotdog?”Linear Programming: “What to put in a hotdog?”

Approximation Algorithms: KnapsackApproximation Algorithms: Knapsack

NP-completeness: ReductionsNP-completeness: Reductions

Classifying problemsClassifying problems

Network Flow: Steepest Assent, Edmonds-Karp, Network Flow: Steepest Assent, Edmonds-Karp, MatchingMatching

Dynamic Programming: Parsing CFGDynamic Programming: Parsing CFG

Greedy Algorithms: MatroidsGreedy Algorithms: Matroids

Recursion: ParsingRecursion: Parsing

Divide and Conquer: Fast Fourier TransformationsDivide and Conquer: Fast Fourier Transformations

Topics:Topics:

Page 3: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

The Pebble GameThe Pebble Game

Page 4: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

The Pebble GameThe Pebble Game

• Used for studying time-space Used for studying time-space trade-off trade-off

• One player game, played on a DAGOne player game, played on a DAG

Page 5: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Output nodes

Nodes

Input nodes

Formalization:Formalization:

• Directed acyclic graphDirected acyclic graph

• Bounded in-degreeBounded in-degree

Page 6: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Three main rules:Three main rules:

2.2. A pebble can be placed on a node A pebble can be placed on a node vv if all predecessors of the node if all predecessors of the node vv are are marked with pebbles marked with pebbles

3.3. A pebble can be removed from a A pebble can be removed from a node at any time node at any time

NoteNote: : a pebble removed from the graph can be ‘reused’a pebble removed from the graph can be ‘reused’

1.1. A pebble can be placed A pebble can be placed on any input nodeon any input node

Page 7: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Strategy:Strategy:sequence of legal moves which ends sequence of legal moves which ends in pebbling the distinguished node in pebbling the distinguished node ff

The Goal:The Goal:to place a pebble on some to place a pebble on some previously distinguished node previously distinguished node ff while minimizing the number while minimizing the number of pebbles usedof pebbles used

A move:A move:placing or removing one of the placing or removing one of the pebblespebblesaccording to the three given according to the three given rulesrules

f

Page 8: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

30

70

60

50

40

20107 moves and 7 pebbles

Example 1

Page 9: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

30

70

60

50

40

201011 moves and 3 pebbles

Example 2

Page 10: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Interpretation:Interpretation:

1.1. A pebble can be placed A pebble can be placed on any input node ~ LOADon any input node ~ LOAD

2.2. A pebble can be placed on A pebble can be placed on a node a node vv if all predecessors of the node if all predecessors of the node vv are marked with pebbles ~ COMPUTE are marked with pebbles ~ COMPUTE

3.3. A pebble can be removed form a A pebble can be removed form a node at any time ~ DELETE node at any time ~ DELETE

• Use as few pebbles as possible ~ # ~ # REGISTERSREGISTERS• Use as few moves as possible ~ TIME~ TIME

input nodes

nodes

output nodes

Page 11: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

In general:In general:

How many pebbles How many pebbles are required to pebble a are required to pebble a

graphgraph with n nodes?with n nodes?

Page 12: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Pyramid graph PPyramid graph Pkk::

Page 13: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Pyramid graph PPyramid graph Pkk::

Fact 1:

Every pebbling strategy for Pk (k > 1)must use AT LEAST k + 1 pebbles.

That is Ω( ) pebbles expressed in number of edges n.

n√

Page 14: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Pyramid graph PPyramid graph Pkk: :

k = 5

We needat least:

k + 1 = 6

Page 15: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Pyramid graph PPyramid graph Pkk: :

Let’s considerhaving

k = 5 pebbles

Page 16: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Arbitrary graph with restricted Arbitrary graph with restricted in-degree (d =2):in-degree (d =2):

Fact 2:

Every graph of in-degree 2 can be pebbledwith O(n/log n) pebbles (n = # nodes in the graph).

Page 17: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Arbitrary graph with restricted Arbitrary graph with restricted in-degree (d =2):in-degree (d =2):

Proof:

• Recursive pebbling strategy

• Cases

• Recursions for each case

• Solutions:P(n) = O(n/log n)

O(n/log n)

Page 18: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

A Pebble problemA Pebble problem

Pebble a DAG that has a rectangle of nodes that is w wide and h high (h <<w).

h

w

The goal is to put a pebble on any single node on the top row.

For each node v (not on the bottom row),there will be d nodes In(v) = {u1, u2,…ud} on the previous row with edges to v.

v

u1 u2 ud…

Page 19: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Dynamic Programming

1. Algorithm that uses as many pebbles (memory) as needed, but does not redo any work

2. Loop invariant

3. How much time and how many pebbles?

Page 20: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Dynamic Programming algorithm

Place a pebble on each of the nodes on the bottom row

After the i th iteration: there is a pebble on each node of the i th row from the bottom

Next iteration: place a pebble on each nodeon the (i +1)st row and remove pebbles from thei th row so they can be reused

Exit when i =h

Loop Invariant

Progress made, LI maintained

Page 21: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Time and pebbles (space) needed

Time = O(h *w)

Pebbles = 2 *w = O(w)

Page 22: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Recursive Backtracking

Task: to place a pebble on some node v whichis r rows from the bottom

Algorithm (recursive) to accomplish this taskthat re-does work but uses as few pebbles aspossible

Time(r ) and Pebbles(r) are time and pebblesused to place a pebble on one node r rowsfrom the bottom

Page 23: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Recursive Backtracking algorithm

My task is to place a pebble on some node v which is r rows from the bottom

I ask a friend, for each of the d nodes ui In(v) to place a pebble on ui

Once there is a pebble on all nodes ui In(v), I place a pebble on node v

Page 24: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Time(r ) and Pebbles(r)

Time(r) = d * Time(r-1) + 1 ≈ d * Time(r-1) =

= d(r-1)

Pebbles(r ) = Pebbles(r-1) + (d – 1) =

= (d - 1) * (r – 1) + 1

Page 25: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Conclusion: time-space trade-off

Time comparison

DP: (h * w)

RB: (d (h-1))

Space comparison

DP: (w)

RB: (d * h) where h << w

Page 26: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

References:

1. Gems of theoretical computer science U. Schöning, R. J. Pruim

2. Asymptotically Tight Bounds on Time-Space Trade-offs in a Pebble Game T. Lengauer, R. E. Tarjan

3. Theoretical Models 2002/03 P. van Emde Boas

Page 27: Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project

Thank you for your attention Thank you for your attention

Questions ?Questions ?