Presentation is loading. Please wait.

Presentation is loading. Please wait.

עידן שני ביה"ס למדעי המחשב אוניברסיטת תל-אביב

Similar presentations


Presentation on theme: "עידן שני ביה"ס למדעי המחשב אוניברסיטת תל-אביב"— Presentation transcript:

1 עידן שני ביה"ס למדעי המחשב אוניברסיטת תל-אביב
כוחם של סריגים The power of grids עידן שני ביה"ס למדעי המחשב אוניברסיטת תל-אביב

2 Overview What is Grid: definition and meaning
Finding the Closest pair (CP): upper bound and randomization Computing (slowly) 2-approximation of min k-disk Corollary for min k-disk when k = Ω(n) Linear 2-approximation of min k-disk

3 What is a Grid? Every point in P is mapped:
Meaning: partition of the plane to αxα squares In fact, we divided the points of P according to Gα So, lets be Gridy!

4 The goal: CP(P) Lemma 1: Let P be a set of points contained inside a square with side = CP(P), then |P|≤4 Proof: אגב, האם תתכנה בריבוע 4 נקודות? 4

5 Alg. 1: CP(P)<α? Store the points of P in Gα: for every non-empty grid cell, maintain a linked list of points from P (for each new point, add it, or create a new list) Insertion time: constant. Overall: linear. Why? for every new point, we have to check against constant number of old points And what about higher dimensions? 5

6 And What About CP(P)? Begin with 2 points and add one at each iteration Check CP(P)<α? If needed, update α, and compute Gα(P) Running time: For i≥3, let Xi be an indicator variable that is one if and only if αi<αi-1. Observe that E[Xi] = Pr[Xi=1] (indicator variable) t = ∑Xi (t: the number of different values of α) Running time = O(n+nt) t is possibly Ω(n) (leads to quadratic time!) 6

7 Still Running… So, let’s spice it up by adding randomization, and bound Pr[Xi=1]: Pr[Xi=1] = And thus: Which leads to O(n∙logn) running time of the algorithm! But we want expected linear time (Gridy, aren’t we?) Pr[αi<αi-1] ≤ 2/i (Why?!) 7

8 A Closer Look: Linear expected time!
Intuitively, the last α-updates are expensive, but rare: Linear expected time!

9 Overview What is Grid: definition and meaning
Finding the Closest pair (CP): upper bound and randomization Computing (slowly) 2-approximation of min k-disk Corollary for min k-disk when k = Ω(n) Linear 2-approximation of min k-disk 9 9

10 Min. k-disk preliminaries
Dopt(P,k): min. disk containing k points of P ropt(P,k): the radius of Dopt(P,k) A generalization of CP (k=2) Given a point q, we can easily [O(n)] find the k nearest points to q in P (using selection alg.) 10

11 Slow 2-approx. Dopt(P,k) [aDCS(P,k) - slow disk cover algorithm]
Compute (non-uniform!) partition of P to horizontal and vertical strips of (about) k/4 points each: X is the set of the partition intersections compute the smallest k-disk around every point of X Return the smallest disk computed v1 vm h1 hm 11

12 aDCS(P,k) discussion Dopt(P,k) must contain at least one point of X
|X|=O((n/k)2) → O(n∙(n/k)2) running time Dopt(P,k) must contain at least one point of X Dopt Computed disk For a point of X in Dopt(P,k), it yields the required 2-approximation (why?) 2∙ropt X 12

13 Remarks [aDCS(P,k)] When k=Ω(n) the running time is linear [O(n∙(n/k)2)] If k>n let the algorithm pick an arbitrary point of P, and compute the min. disk containing P around it. So, now we have a linear algorithm to compute a 2-approximation of the k-disk-cover problem for k = Ω(n) 13

14 Linear k-disk 2-approx. preliminaries
k-gradation (P1,...,Pm) of P is a sequence of subsets of P, such that: Pm = P Pi is formed by picking each point of Pi+1 with prob. ½ |P1| ≤ k |P2| > k notice: if α ≤ 2∙ropt(P,k) then any cell-grid of Gα contains at most 5∙k points 14

15 The algorithm Intuition: never too many points in grid-cell (5k turns to 10k), and therefore linearity of aDCS(Pi,k) 15

16 I’m sure you’ve all understand, but still… let’s see an example
First, compute α1 (no G1 cell with more than 5k points of P1). Let’s see what happens in the 7th iteration: Computing G7 for P8 (no more than 10k points in every cell expected) For every ‘heavy’ cluster, approximate ropt(p8, k). Return the smallest. Notice: no more than 5k points of P8 in every G8 cell 16

17 Analysis: correctness
For i = 1,...,m, ropt(Pi,k) ≤ αi ≤ 2∙ropt(Pi,k) Proof: Consider the optimal disk Di that realizes ropt(Pi,k) Observe that there is a cluster c of Gi-1 that contains Di, as αi-1 ≥ αi (why?) Thus, when handling the cluster c, Di∩Pi c, and the correctness follows aDCS correctness Finally, apply i = m 17

18 What do have? What is Grid: definition and meaning
Finding the Closest pair (CP): upper bound and randomization (expected linear time) Computing 2-approximation of min k-disk (for k = Ω(n), in expected linear time) An algorithm that claims to compute 2-approximation of min k-disk for every k. 18 18

19 The algorithm 19

20 Analysis: running time
‘Gradation’: sampling time is so, the expected running time is: 20

21 So, what can go wrong? Analysis: running time (2)
Too many points in a cell (say, more then 50k) Solution: Chernoff bound Too many possible (non-uniform) grids Solution: God is in the details (no more then n3 possible grids) v1 vm h1 hm 21 21

22 Analysis: running time (cont. 1)
Let S be a set of points from Pi, where 50∙k≤|S|, so for δ=4/5: Define - excess(Gα(P)): For any t > 0, let β = ceil(3∙ln(n)/8k)+t. The probability that Gi(Pi) has excess ≥ β, is at most exp(-8kt). But, since there are no more than n3 possible grids*: Chernoff bound G’s side length 22

23 Analysis: running time (cont. 2)
23

24 Analysis: running time (cont. 3)
...and the total expected running time of the algorithm inside the inner loop is: 24

25 Overview What is Grid: definition and meaning
Finding the Closest pair (CP): upper bound and randomization Computing (slowly) 2-approximation of min k-disk Corollary for min k-disk when k = Ω(n) Linear 2-approximation of min k-disk 25 25


Download ppt "עידן שני ביה"ס למדעי המחשב אוניברסיטת תל-אביב"

Similar presentations


Ads by Google