+ All Categories
Home > Documents > Lecture 16

Lecture 16

Date post: 11-May-2015
Category:
Upload: rajiv-omar
View: 54 times
Download: 3 times
Share this document with a friend
Popular Tags:
47
Randomized Algorithms CS648 Lecture 16 Randomized Incremental Construction (Backward analysis) 1
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


Recommended