Top Banner
Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) 1
20

Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

Dec 16, 2015

Download

Documents

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: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

Randomized AlgorithmsCS648

Lecture 15Randomized Incremental Construction

(building the background)

1

Page 2: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

Partition Theorem

A set of events ,…, defined over a probability space (,P) is said to induce a partition of if• = • =∅ for all

Partition Theorem:

2

P(B) = )

ΩB

) ∙ ) This theorem solves

many difficult problems magically. But one needs some

experience in order to apply it effectively. You will realize it

soon.

Page 3: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

PROBLEM 1FIND-MIN PROBLEM

3

Page 4: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

Find-Min algorithm

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

Question: If elements of A are permuted randomly uniformly, what is the expected number of times variable is updated ?

: no. of times is updated.

4

8 5 16 11 32 4 57 6 19 82 7 42 2 23

1 2 3 4 5 6 7 8 9 10 11 12 13 14

A

A[] A[] ;

??

Page 5: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

Find-Min algorithm

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

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

Using Partition Theorem, =

5

𝒊 𝒏−𝟏1 2 …

A

𝐏 (𝑿¿¿ 𝒊=𝟏∨𝓔𝒂)¿ 𝐏 (𝓔𝒂)

First elements

Though this equation is perfectly correct, you won’t be able to proceed from this

point onwards to find . Can you find the reason behind its

uselessness ?

Page 6: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

PROBLEM 2CLOSEST PAIR OF POINTS

6

Page 7: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

Closest Pair of Points

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

Deterministic algorithms:• O() : Trivial algorithm• O() : Divide and Conquer based algorithm

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

7

Page 8: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

Notations and assumptions

Notations: • : set of points in plane.

• Coordinates of each point are positive integers.

• distance(,) : Euclidean distance between and .

Assumption:

• Distance between each pair of points is distinct.

8

Page 9: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

A discrete math exercise

Exercise: What is the maximum number of points that can be placed in a unit square such that the minimum distance is at least 1 ?Answer: 4.

This exercise is used is deterministic algorithm as well the randomized algorithm that we shall discuss now.

9

1

1

√2

If there are more than 4 points, at least one

of the four small squares will have more

than 1 points.

Page 10: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

Overview of the randomized algorithm

• Incremental algorithm: starts with a set of 2 points, computes their distance; inserts 3rd point and updates the closest pair distance; inserts 4th point and updates the closest pair distance; … • Uses an efficient data structure, called Grid, to facilitate efficient

processing during ith step: - To determine if ith point is going to change the closest pair distance.

10

Page 11: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

Grid()

A data structure with operations:• Locate_cell(, ): Locates the cell to which belongs.

• Report_points(, ): Report all points belonging to cell .

• Insert_point(, ): Insert point in grid .

• Build_Grid(): Build grid for with parameter .

11

𝜹

𝜹

: set of points

: distance between closest pair of points in .

Page 12: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

Grid()

Height Balanced Binary search tree

Dynamic hashing

Locate_cell(, ) (1)

Report_points(, ) (1)

Insert_point(, ) (1) expected

Build_Grid() ) expected

12

The following time bounds are possible.

Excluding Insert_point() operation, show as a homework, that we can achieve all other bounds using static hashing discussed in this course.

Page 13: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

Closest Pair of Points

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 ;

13

Page 14: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

th iteration

14

𝜹𝒊−𝟏

𝜹𝒊−𝟏

:𝒑𝒊

We just need to

insert

Page 15: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

th iteration

15

𝜹𝒊−𝟏

𝜹𝒊−𝟏

𝜹𝒊

:𝒑𝒊

We need to rebuild the grid

Page 16: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

th iteration

16

𝜹𝒊

𝜹𝒊

:𝒑𝒊

Page 17: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

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 ;

17

O(1)

O(1)

O(1)

for constant

Page 18: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

running time of th iteration

: running time of th iteration

E[] = ??

Question: What is ?

depends upon which depends upon the first points.

So we need to use Partition theorem to calculate .

18

O(1) + ∙

Page 19: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

Calculating

Notations:

• : set of all subsets of of size .

• For any , : first points are (some permutation of) .

=

19

𝐏 (𝜹¿¿ 𝒊<𝜹𝒊−𝟏∨𝓔𝒂)¿ 𝐏 (𝓔𝒂)

Though this equation is perfectly correct, you won’t be able to proceed from this

point onwards to find Can you find the reason behind its

uselessness ?

Page 20: Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.

Homework Exercise

• Investigate the cause of problem in our forward analysis for each of the two problems.

• Try to find alternate approach for analysis. (Backward analysis )

• Provide efficient implementation of Grid data structure.

20

I am hopeful that at least one of

you will reinvent this technique on

his/her own before next class.