Top Banner
Randomized Algorithms CS648 Lecture 16 Randomized Incremental Construction (Backward analysis) 1
47
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture 16

Randomized AlgorithmsCS648

Lecture 16Randomized Incremental Construction

(Backward analysis)

1

Page 2: Lecture 16

PROBLEM 1FIND-MIN PROBLEM

2

Page 3: Lecture 16

Find-Min algorithm

Find-Min(A[1..]){ A[1]; For to do { if (A[] ) A[] ; } return ; }

: no. of times is updated.

3

??

𝒏−𝟏1 2 …

A

Probability that “A[] is smaller than {A[],…, A[]}”

Page 4: Lecture 16

Forward analysis for

Find-Min(A[1..]){ A[1]; For to do { if (A[] ) A[] ; } return ; }

Notations:• : set of all subsets of A of size .• For any , : first elements of A are some permutation of .

Using Partition Theorem, =

4

𝒊 𝒏−𝟏1 2 …

A

First elements

Page 5: Lecture 16

Forward analysis for

: a subset of elements. = “Given that first elements of A are some permutation of , what is prob. that = ?”

For this event to happen, A[] must be smaller than every element of . depends upon .

For example, if the smallest element of has rank in A, then = ??

5

𝒌−𝟏𝒏−𝒊+𝟏

Dependency on makes it hard to calculate

Page 6: Lecture 16

Backward analysis for

Find-Min(A[1..]){ A[1]; For to do { if (A[] ) A[] ; } return ; }

Notations:• : set of all subsets of A of size .• For any , : first elements of A are some permutation of .

Using Partition Theorem, =

6

𝒊 𝒏−𝟏1 2 …

A

First elements

Page 7: Lecture 16

Backward analysis for

: a subset of elements. = “Given that first elements of A are some permutation of , what is prob. that = ?”

For this event to happen, the smallest element of must appear at A[].

=

Every element of is equally likely to appear at place A[].

= ??

7

“the smallest element of appear at A[]”

𝟏𝒊

Fact: A is permuted randomly uniformly

Same for each

Page 8: Lecture 16

Backward analysis for

Find-Min(A[1..]){ A[1]; For to do { if (A[] ) A[] ; } return ; }

Notations:• : set of all subsets of A of size .• For any , : first elements of A are some permutation of .

Using Partition Theorem, = = =

8

𝒊 𝒏−𝟏1 2 …

A

First elements

Page 9: Lecture 16

PROBLEM 2CLOSEST PAIR OF POINTS

9

Page 10: Lecture 16

Closest Pair of Points

Problem Definition:Given a set of points in plane, compute the pair of points with minimum Euclidean distance.

Randomized algorithm:• O() : Randomized Incremental Construction based algorithm

10

Page 11: Lecture 16

th iteration

11

𝜹𝒊−𝟏

𝜹𝒊−𝟏

Grid structure for first points

Page 12: Lecture 16

Analysis of th iteration

Closest-pair-algorithm() Let <,,…, > be a uniformly random permutation of ; distance(,); Build_Grid(, ); For to do { Step 1: locate the cell of the grid containing ; Step 2: find the point closest to ; let = distance(, ); Step 3: If ; Insert(,); Else ; Build_Grid(, ); } return ;

12

O(1)

O(1)

O(1)

for constant

Page 13: Lecture 16

running time of th iteration

: running time of th iteration

E[] = ??

Question: What is ?

13

O(1) + ∙

Page 14: Lecture 16

Forward analysis for

Closest-pair-algorithm() Let <,,…, > be a uniformly random permutation of ; distance(,); Build_Grid(, ); For to do { Step 1: locate the cell of the grid containing ; Step 2: find the point closest to ; let = distance(, ); Step 3: If ; Insert(,); Else ; Build_Grid(, ); } return ;

14

Page 15: Lecture 16

Forward analysis for

: a subset of points from .:first points of are some permutation of

= ??

Calculating :

Let be the set of all subsets of of size .

=

15

𝜹𝒊−𝟏

𝜹𝒊−𝟏

Grid structure for first points

Depends upon

Page 16: Lecture 16

Backward analysis for

Closest-pair-algorithm() Let <,,…, > be a uniformly random permutation of ; distance(,); Build_Grid(, ); For to do { Step 1: locate the cell of the grid containing ; Step 2: find the point closest to ; let = distance(, ); Step 3: If ; Insert(,); Else ; Build_Grid(, ); } return ;

16

Page 17: Lecture 16

Backward analysis for

: a subset of points from .: first points of are some permutation of

= ??

Calculating :

Let be the set of all subsets of of size .

= = =

17

𝜹𝒊

𝜹𝒊

𝟐𝒊

= Grid structure for first points

Page 18: Lecture 16

running time of th iteration

: running time of th iteration

E[] = O(1) + ∙ = O(1) + ∙ = O(1)

Expected running time of the algorithm :

Theorem:There exists a linear time Las Vegas algorithm to compute closest pair of points in plane.

18

¿∑𝒊≤𝒏

O(1) =

Page 19: Lecture 16

RANDOMIZED INCREMENTAL CONSTRUCTION

19

Page 20: Lecture 16

Randomized Incremental Construction

• Permute the elements of input randomly uniformly.

• Build the structure incrementally.

• Keep some data structure to perform th iteration efficiently.

• Use Backward analysis to analyze the expected running time.

20

Page 21: Lecture 16

Randomized Incremental Construction

• Convex Hull of a set of points

• Trapezoidal decomposition of a set of segments.

• Convex polytope of a set of half-planes

• Smallest sphere enclosing a set of points.

• Linear programming in finite dimensions.

21

Page 22: Lecture 16

PROBLEM 3CONVEX HULL OF POINTS

22

Page 23: Lecture 16

Convex hull of Points

Problem definition: Given points in a plane, compute a convex polygon of smallest area that encloses all the points.

23

Page 24: Lecture 16

Convex hull of Points

Deterministic algorithm:• O() time algorithm.• Many algorithms exist:

Grahams Scan, Jarvis’s march, divide and conquer,…

Randomized algorithm:• O() time algorithm.• Based on Randomized Incremental Construction.• Generalizable to higher dimensions.

24

Page 25: Lecture 16

Randomized algorithm for convex hull

Convex-hull-algorithm(){ Let <,,…, > be a uniformly random permutation of ; triangle(,, ); For to do insert and update return ;}

25

Page 26: Lecture 16

A simple exercise from geometry

Exercise: Given a line L and two points p and q, determine whether the points lie on the same/different sides of L.

26

L p

q

q

𝒚=𝒎𝒙+𝒄

Page 27: Lecture 16

27

Conflict graph : a powerful data structure

𝒄𝟒

𝒄𝟏

𝒄𝟐

𝒄𝟑

𝒄𝟓𝒄𝟔

𝒄𝟕

𝒄𝟖

conespoints𝒄𝟐

𝒄𝟑

𝒄𝟒

𝒄𝟓

𝒄𝟔

𝒄𝟕

𝒄𝟖

𝒄𝟏

Page 28: Lecture 16

Before entering the for loop

28

Page 29: Lecture 16

Before entering the for loop

29

𝒄𝟏

𝒄𝟐

𝒄𝟑

𝒄𝟏

𝒄𝟐

𝒄𝟑

points cones

Page 30: Lecture 16

INSERTING TH POINT

30

Page 31: Lecture 16

th iteration

31

𝒄𝟏

𝒄𝟑

𝒄𝟒

𝒄𝟓

𝒄𝟔

𝒄𝟕

𝒄𝟖

𝒄𝟐

Page 32: Lecture 16

th iteration

32

𝒄𝟏

𝒄𝟐

𝒄𝟑

𝒄𝟒

𝒄𝟓

𝒄𝟔

𝒄𝟕

𝒄𝟖

𝒄𝟐

𝒄𝟑

𝒄𝟒𝒄𝟓𝒄𝟔

𝒄𝟕

𝒄𝟖

points cones𝒄𝟏

Page 33: Lecture 16

th iteration

33

𝒄𝟏

𝒄𝟐

𝒄𝟑

𝒄𝟒

𝒄𝟓

𝒄𝟔

𝒄𝟕

𝒄𝟖

𝒄𝟐

𝒄𝟑

𝒄𝟒𝒄𝟓𝒄𝟔

𝒄𝟕

𝒄𝟖

points cones𝒄𝟏

Page 34: Lecture 16

th iteration

34

𝒄𝟏

𝒄𝟐

𝒄𝟑

𝒄𝟒

𝒄𝟓

𝒄𝟔

𝒄𝟕

𝒄𝟖

𝒄𝟐

𝒄𝟑

𝒄𝟒𝒄𝟓𝒄𝟔

𝒄𝟕

𝒄𝟖

points cones𝒄𝟏

Page 35: Lecture 16

th iteration

35

𝒄𝟏

𝒄𝟐

𝒄𝟑

𝒄𝟒

𝒄𝟓

𝒄𝟔

𝒄𝟕

𝒄𝟖

𝒄𝟐

𝒄𝟑

𝒄𝟒𝒄𝟓𝒄𝟔

𝒄𝟕

𝒄𝟖

points cones𝒄𝟏

Page 36: Lecture 16

th iteration

36

𝒄𝟏

𝒄𝟐

𝒄𝟑

𝒄𝟒

𝒄𝟓

𝒄𝟔

𝒄𝟕

𝒄𝟖

𝒄𝟐

𝒄𝟑

𝒄𝟒𝒄𝟓𝒄𝟔

𝒄𝟕

𝒄𝟖

points cones𝒄𝟏

Page 37: Lecture 16

th iteration

37

𝒄𝟏

𝒄𝟐

𝒄𝟑

𝒄𝟒

𝒄𝟓

𝒄𝟔

𝒄𝟕

𝒄𝟖

𝒄𝟐

𝒄𝟑

𝒄𝟒𝒄𝟓𝒄𝟔

𝒄𝟕

𝒄𝟖

points cones𝒄𝟏

Page 38: Lecture 16

th iteration

38

𝒄𝟏

𝒄𝟐

𝒄𝟑

𝒄𝟒

𝒄𝟓

𝒄𝟔

𝒄𝟕

𝒄𝟖

𝒄𝟐

𝒄𝟑

𝒄𝟒𝒄𝟓𝒄𝟔

𝒄𝟕

𝒄𝟖

points cones𝒄𝟏

Page 39: Lecture 16

th iteration

39

𝒄𝟏

𝒄𝟐

𝒄𝟑

𝒄𝟒

𝒄𝟓

𝒄𝟔

𝒄𝟕

𝒄𝟖

𝒄𝟐

𝒄𝟑

𝒄𝟒𝒄𝟓𝒄𝟔

𝒄𝟕

𝒄𝟖

points cones𝒄𝟏

Page 40: Lecture 16

th iteration

40

𝒄𝟏

𝒄 ′

𝒄

𝒄𝟔

𝒄𝟕

𝒄𝟖

𝒄 ′

𝒄

𝒄𝟔

𝒄𝟕

𝒄𝟖

points cones𝒄𝟏

Page 41: Lecture 16

Running time of th iterationRunning time of th iteration is of the order of

• Number of edges destroyed

• Number of new edges created

• Number of points in the two adjacent cones that get created

Question: What is the max. number of new edges created in an iteration ?Answer: 2 Number of edges created during the algorithm = O() Since every edge destroyed was once created, so Total number of edges destroyed Total number of edges decreated

41

Total time for iterations = O()

𝑿 𝒊

Page 42: Lecture 16

Backward analysis of th iteration

: a subset of points from .: first points of are some permutation of

= ??

42

Page 43: Lecture 16

Backward analysis of th iteration

: a subset of points from .: first points of are some permutation of

= ??

43

𝒄𝟏𝒄𝟐

𝒄𝟑

𝒄𝟒

𝒄𝟓

𝒄𝟔

𝒄𝟕

𝒄𝟖 𝒑𝟏

𝒑𝟐

𝒑𝟑

𝒑𝟒

𝒑𝟓

𝒑𝟔

𝒑𝟕

𝒑𝟖

Page 44: Lecture 16

Backward analysis of th iteration

: a subset of points from .: first points of are some permutation of

= ??

44

𝒄𝟏𝒄𝟐

𝒄𝟑

𝒄𝟒

𝒄𝟓

𝒄𝟔

𝒄𝟕

𝒄𝟖 𝒑𝟏

𝒑𝟐

𝒑𝟑

𝒑𝟒

𝒑𝟓

𝒑𝟔

𝒑𝟕

𝒑𝟖

Page 45: Lecture 16

Backward analysis of th iteration

: a subset of points from .: first points of are some permutation of

= ??

Calculating :

Let be the set of all subsets of of size .

= =

45

𝒄𝟏𝒄𝟐

𝒄𝟑

𝒄𝟒

𝒄𝟓

𝒄𝟔

𝒄𝟕

𝒄𝟖 𝒑𝟏

𝒑𝟐

𝒑𝟑

𝒑𝟒

𝒑𝟓

𝒑𝟔

𝒑𝟕

𝒑𝟖 𝟐(𝒏− 𝒊)𝒊

=

Page 46: Lecture 16

Running time of the algorithm

Expected running time of ith iteration = + O(1) = O()

Expected running time of the algorithm = O()

Theorem: There is an O() time Las Vegas algorithm for computing convex hull.

46

Page 47: Lecture 16

47