Download presentation
Presentation is loading. Please wait.
Published byPriscilla Mathews Modified over 9 years ago
1
Advanced Algorithm Design and Analysis Student: Gertruda Grolinger Supervisor: Prof. Jeff Edmonds CSE 4080 Computer Science Project
2
Linear Programming: “What to put in a hotdog?” Approximation Algorithms: Knapsack NP-completeness: Reductions Classifying problems Network Flow: Steepest Assent, Edmonds-Karp, Matching Matching Dynamic Programming: Parsing CFG Greedy Algorithms: Matroids Recursion: Parsing Divide and Conquer: Fast Fourier Transformations Topics:
3
The Pebble Game
4
Used for studying time-space trade-off Used for studying time-space trade-off One player game, played on a DAG One player game, played on a DAG
5
Output nodes Nodes Input nodes Formalization: Directed acyclic graph Directed acyclic graph Bounded in-degree Bounded in-degree
6
Three main rules: 2. A pebble can be placed on a node v if all predecessors of the node v are marked with pebbles 3. A pebble can be removed from a node at any time Note: a pebble removed from the graph can be ‘reused’ 1. A pebble can be placed on any input node on any input node
7
Strategy: sequence of legal moves which ends in pebbling the distinguished node f The Goal: to place a pebble on some previously distinguished node f while minimizing the number of pebbles used A move: placing or removing one of the pebbles according to the three given rules f
8
30 70 60 50 40 2010 7 moves and 7 pebbles Example 1
9
30 70 60 50 40 2010 11 moves and 3 pebbles Example 2
10
Interpretation: 1. A pebble can be placed on any input node ~ LOAD on any input node ~ LOAD 2. A pebble can be placed on a node v if all predecessors of the node a node v if all predecessors of the node v are marked with pebbles ~ COMPUTE v are marked with pebbles ~ COMPUTE 3. A pebble can be removed form a node at any time ~ DELETE ~ # REGISTERS Use as few pebbles as possible ~ # REGISTERS ~ TIME Use as few moves as possible ~ TIME input nodes nodes output nodes
11
In general: How many pebbles are required to pebble a graph with n nodes? with n nodes?
12
Pyramid graph P k :
13
Fact 1: Every pebbling strategy for P k (k > 1) must use AT LEAST k + 1 pebbles. That is Ω ( ) pebbles expressed in number of edges n. n √
14
Pyramid graph P k : k = 5 We need at least: k + 1 = 6
15
Pyramid graph P k : Let’s consider having k = 5 pebbles
16
Arbitrary graph with restricted in-degree (d =2): Fact 2: Every graph of in-degree 2 can be pebbled with O(n/log n) pebbles (n = # nodes in the graph).
17
Arbitrary graph with restricted in-degree (d =2): Proof : Recursive pebbling strategy Cases Recursions for each case Solutions: P(n) = O(n/log n) O(n/log n)
18
A 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) = {u 1, u 2,…u d } on the previous row with edges to v. v u1u1 u2u2 udud …
19
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?
20
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 node on the (i +1) st row and remove pebbles from the i th row so they can be reused Exit when i =h Loop Invariant Progress made, LI maintained
21
Time and pebbles (space) needed Time = O(h *w) Pebbles = 2 *w = O(w)
22
Recursive Backtracking Task: to place a pebble on some node v which is r rows from the bottom Algorithm (recursive) to accomplish this task that re-does work but uses as few pebbles as possible Time(r ) and Pebbles(r) are time and pebbles used to place a pebble on one node r rows from the bottom
23
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 u i In(v) to place a pebble on u i Once there is a pebble on all nodes u i In(v), I place a pebble on node v
24
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
25
Conclusion : time-space trade-off Time comparison DP: (h * w) RB: (d (h-1) ) Space comparison DP: (w) RB: (d * h) where h << w
26
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
27
Thank you for your attention Thank you for your attention Questions ?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.