Date post: | 11-May-2015 |
Category: |
Documents |
Upload: | rajiv-omar |
View: | 54 times |
Download: | 3 times |
Randomized AlgorithmsCS648
Lecture 16Randomized Incremental Construction
(Backward analysis)
1
PROBLEM 1FIND-MIN PROBLEM
2
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[]}β
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
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
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
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
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
PROBLEM 2CLOSEST PAIR OF POINTS
9
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
th iteration
11
πΉπβπ
πΉπβπ
Grid structure for first points
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
running time of th iteration
: running time of th iteration
E[] = ??
Question: What is ?
13
O(1) + β
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
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
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
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
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) =
RANDOMIZED INCREMENTAL CONSTRUCTION
19
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
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
PROBLEM 3CONVEX HULL OF POINTS
22
Convex hull of Points
Problem definition: Given points in a plane, compute a convex polygon of smallest area that encloses all the points.
23
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
Randomized algorithm for convex hull
Convex-hull-algorithm(){ Let <,,β¦, > be a uniformly random permutation of ; triangle(,, ); For to do insert and update return ;}
25
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
π=ππ+π
27
Conflict graph : a powerful data structure
ππ
ππ
ππ
ππ
ππππ
ππ
ππ
conespointsππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
Before entering the for loop
28
Before entering the for loop
29
ππ
ππ
ππ
ππ
ππ
ππ
points cones
INSERTING TH POINT
30
th iteration
31
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
th iteration
32
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππππππ
ππ
ππ
points conesππ
th iteration
33
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππππππ
ππ
ππ
points conesππ
th iteration
34
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππππππ
ππ
ππ
points conesππ
th iteration
35
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππππππ
ππ
ππ
points conesππ
th iteration
36
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππππππ
ππ
ππ
points conesππ
th iteration
37
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππππππ
ππ
ππ
points conesππ
th iteration
38
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππππππ
ππ
ππ
points conesππ
th iteration
39
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππππππ
ππ
ππ
points conesππ
th iteration
40
ππ
π β²
π
ππ
ππ
ππ
π β²
π
ππ
ππ
ππ
points conesππ
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()
πΏ π
Backward analysis of th iteration
: a subset of points from .: first points of are some permutation of
= ??
42
Backward analysis of th iteration
: a subset of points from .: first points of are some permutation of
= ??
43
ππππ
ππ
ππ
ππ
ππ
ππ
ππ ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
Backward analysis of th iteration
: a subset of points from .: first points of are some permutation of
= ??
44
ππππ
ππ
ππ
ππ
ππ
ππ
ππ ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ
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
ππππ
ππ
ππ
ππ
ππ
ππ
ππ ππ
ππ
ππ
ππ
ππ
ππ
ππ
ππ π(πβ π)π
=
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
47