SlideShare une entreprise Scribd logo
1  sur  50
Télécharger pour lire hors ligne
An overview of lecture
• Geometric Algorithms
– Range searching.
– Nearest neighbor.
– Finding intersections of geometric objects.
• An optimal parallel algorithm for the 2D
convex hull problem,
• Some applications of the 2D convex hull
algorithm.
Geometric search: Overview
• Types of data. Points, lines, planes, polygons,
circles, ...
• This lecture: Sets of N objects.
• Geometric problems extend to higher dimensions.
– Good algorithms also extend to higher dimensions.
– Curse of dimensionality.
• Basic problems.
– Range searching.
– Nearest neighbor.
– Finding intersections of geometric objects.
Range Searching
1D Range Search
• Extension to symbol-table ADT with comparable keys.
– Insert key-value pair.
– Search for key k.
– How many records have keys between k1 and k2?
– Iterate over all records with keys between k1 and k2.
• Application: database queries.
• Geometric intuition.
– Keys are point on a line.
– How many points in a given interval?
insert B B
insert D B D
insert A A B D
insert I A B D I
insert H A B D H I
insert F A B D F H I
insert P A B D F H I P
count G to K 2
search G to K H I
1D Range Search
Implementations
• Range search. How many records have keys between k1 and k2?
• Ordered array. Slow insert, binary search for k1 and k2 to find range.
• Hash table. No reasonable algorithm (key order lost in hash).
• BST. In each node x, maintain number of nodes in tree rooted at x.
Search for smallest element k1 and largest element k2.
log N
N
log N
countinsert range
ordered array N R + log N
hash table 1 N
BST log N R + log N
nodes examined
within interval
not touched
N = # records
R = # records that match
2D Orthogonal Range Search
• Extension to symbol-table ADT with 2D keys.
– Insert a 2D key.
– Search for a 2D key.
– Range search: find all keys that lie in a 2D range?
– Range count: how many keys lie in a 2D range?
• Applications: networking, circuit design, databases.
• Geometric interpretation.
– Keys are point in the plane.
– Find all points in a given h-v rectangle?
2D Orthogonal Range Search:
Grid Implementation
• Grid implementation.
– Divide space into M-by-M grid of squares.
– Create linked list for each square.
– Use 2D array to directly access relevant square.
– Insert: insert (x, y) into corresponding grid square.
– Range search: examine only those grid squares that could
have points in the rectangle.
LB
RT
2D Orthogonal Range Search:
Grid Implementation Costs
• Space-time tradeoff.
– Space: M2 + N.
– Time: 1 + N / M2 per grid cell examined on average.
• Choose grid square size to tune performance.
– Too small: wastes space.
– Too large: too many points per grid square.
– Rule of thumb: √N by √N grid.
• Running time. [if points are evenly distributed]
– Initialize: O(N).
– Insert: O(1).
– Range: O(1) per point in range. LB
RT
Clustering
• Grid implementation. Fast, simple solution for well-distributed
points.
• Problem. Clustering is a well-known phenomenon in geometric
data.
• Ex: USA map data.
– 80,000 points, 20,000 grid squares.
– Half the grid squares are empty.
– Half the points have 10 others in same grid square.
– Ten percent have 100 others in same grid square.
• Need data structure that gracefully adapts to data.
Space Partitioning Trees
• Space partitioning tree. Use a tree to represent the recursive
hierarchical subdivision of d-dimensional space.
• BSP tree:- Recursively divide space into two regions.
• Quad tree:- Recursively divide plane into four quadrants.
• Octree:- Recursively divide 3D space into eight octants.
• kD tree:- Recursively divide k-dimensional space into two half-
spaces.
• Applications.
– Ray tracing.
– Flight simulators.
– N-body simulation.
– Collision detection.
– Astronomical databases.
– Adaptive mesh generation.
– Accelerate rendering in Doom.
– Hidden surface removal and shadow casting.
Grid
Quadtree
kD tree
BSP tree
Quad Trees
• Quad tree. Recursively partition plane into 4 quadrants.
• Implementation: 4-way tree.
• Good clustering performance is a primary reason to choose quad trees
over grid methods.
a
b
c
e
f
g h
d
a h
d ge
b c
f
public class QuadTree {
private Quad quad;
private Value value;
private QuadTree NW, NE, SW, SE;
}
kD Trees
• kD tree. Recursively partition k-dimensional space into 2 halfspaces.
• Implementation: BST, but cycle through dimensions.
• Efficient, simple data structure for processing k-dimensional data.
– Adapts well to clustered data.
– Adapts well to high dimensional data.
– Discovered by an undergrad in an algorithms class!
level ≡ i (mod k)
points
whose ith
coordinate
is less than p’s
points
whose ith
coordinate
is greater than p’s
p
Summary
• Basis of many geometric algorithms:
search in a planar subdivision.
grid 2D tree Voronoi diagram
intersecting
lines
basis N h-v lines N points N points N lines
representation
2D array
of N lists
N-node BST N-node multilist ~N-node BST
cells ~N squares N rectangles N polygons ~N triangles
search cost 1 log N log N log N
extend to kD? too many cells easy
cells too
complicated
use (k-1)D
hyperplane
Geometric Intersection
• Problem. Find all intersecting pairs among set of N geometric objects.
• Applications. CAD, games, movies, virtual reality.
• Simple version: 2D, all objects are horizontal or vertical line
segments.
• Brute force. Test all (N2) pairs of line segments for intersection.
• Sweep line. Efficient solution extends to 3D and general objects.
• Sweep vertical line from left to right.
– Event times: x-coordinates of h-v line segments.
– Left endpoint of h-segment: insert y coordinate into ST.
– Right endpoint of h-segment: remove y coordinate from ST.
– v-segment: range search for interval of y endpoints.
Orthogonal Segment Intersection:
Sweep Line Algorithm
range searchinsert y
delete y
Orthogonal Segment Intersection:
Sweep Line Algorithm
• Sweep line: reduces 2D orthogonal segment intersection
problem to 1D range searching!
• Running time of sweep line algorithm.
– Put x-coordinates on a PQ (or sort). O(N log N)
– Insert y-coordinate into SET. O(N log N)
– Delete y-coordinate from SET. O(N log N)
– Range search. O(R + N log N)
• Efficiency relies on judicious use of data structures.
N = # line segments
R = # intersections
Line Segment Intersection:
Implementation
• Efficient implementation of sweep line algorithm.
– Maintain PQ of important x-coordinates: endpoints and intersections.
– Maintain ST of segments intersecting sweep line, sorted by y.
– O(R log N + N log N).
• Implementation issues.
– Degeneracy.
– Floating point precision.
– Use PQ since intersection events aren't known ahead of time.
The convex hull problem
Input: A set S = (p1, p2,…,pn) of n points on the
plane.
Output: The convex hull CH(S) of these n
points.
• The convex hull is the smallest convex
polygon containing all the n points.
• Each vertex of CH(S) is called an extreme
point and the convex hull is output as a list
of the extreme points.
The convex hull problem
• Let pmax and pmin be two points in the set S with the
maximum and minimum x coordinates.
• Then pmax and pmin are convex hull vertices.
• The line segment divides the convex hull
into two parts, upper hull and lower hull.
max minp p
The convex hull problem
• We use the notation x(p) and y(p) to denote
the x and y coordinates of a point p.
• Given a line L specified by the equation
y = ax + b, and a point q =( , ),
• We say, q is below L if < a + b.
• We also say, q is above L if > a + b.
The convex hull problem
• Given the set S of n points, we can find pmax and
pmin in O(n) time.
• We can find all the points above and below
also in O(n) time.
• We can compute the convex hull of all the points
above and call this as UH(S).
• Similarly, we can compute the convex hull of all
the points below and call this as LH(S).
• At the end, we can stitch these two hulls together
at the two points pmax and pmin.
max minp p
max minp p
max minp p
Sequential complexity
• The convex hull of n planar points can be
constructed in (n log n) time sequentially.
• The lower bound can be proved by
showing that the convex hull problem is
equivalent to sorting.
• We need to design an O(n log n) work
algorithm to achieve optimality.
Computing the upper hull
• We will discuss an algorithm for computing the
upper hull of the set S. The algorithm for
computing the lower hull is exactly the same.
• A line L is tangent to a convex polygon P if all the
vertices of P are on the same side of L.
A divide-and-conquer algorithm
• We discuss a divide-and-conquer
algorithm for computing the upper hull.
There are two phases, top-down and
bottom-up.
• First, we sort the points according to x-
coordinates.
A divide-and-conquer algorithm
• In the top-down phase, we divide the point
set recursively into two parts and compute
the convex hull when the size of each
subproblem is small.
• In the bottom-up phase, we merge these
hulls pairwise to get the upper hull.
• The strategy is exactly similar to the
sequential algorithm for merge sort.
A divide-and-conquer algorithm
Merging two upper hulls
• The main problem in combining two upper hulls
to form a single upper hull is to compute a
common tangent to the two hulls.
• To achieve O(n log n) work, we need to complete
the merging of all the upper hulls at a level of the
tree in O(1) time.
Merging two upper hulls
• We consider two upper hulls UH(S1) and UH(S2).
• Our aim is to find a common tangent to these two
upper hulls.
• We first find a tangent to UH(S2) from a point ri on
UH(S1).
Merging two upper hulls
• Suppose the line is the tangent to UH(S2) from ri.
• Suppose ql is another vertex of UH(S2).
• Given the line riql, we first try to locate .
ii rrq
irq
Merging two upper hulls
• In O(1) time, we can say whether is above or
below the line .
• If the neighboring vertices ql -1 and ql +1 of ql are
on either side of , then is above ql.
irq
irq
i lrq
i lrq
Merging two upper hulls
• Suppose, UH(S2) has s points given in an array
according to their order on UH(S2).
• We allocate processors and divide the points on
UH(S2) into intervals and do a parallel search.
• We can identify the point in time.
s
irq
log
( ) (1)
log
s
O O
s
s
Merging two upper hulls
• Suppose, the common tangent to UH(S1) and
UH(S2) is the line .
• u is on UH(S1) and v is on UH(S2) .
• If we know the line , we can say in O(1) time
whether u is above or below the line .
uv
ii rrq
ii rrq
Merging two upper hulls
• Suppose, there are t points on UH(S1), given in an
array according to their order on UH(S1).
• We divide these t points in intervals, each
interval contains points.
• We now do a parallel search in the following ways.
t
t
Merging two upper hulls
• We allocate processors for the parallel search.
• Suppose ri is the boundary vertex of one of the
intervals.
• For each such ri, we can find the tangent to
UH(S2) in O(1) time using processors.
t s
s
ii rrq
Merging two upper hulls
• Hence, we can identify two boundary vertices rj
and rk such that u is above rj and below rk.
• Hence, u must be one of the vertices in
between rj and rk.
• This computation takes O(1) time and
processors.
t
( )s t O n
Merging two upper hulls
• We can do a similar computation to find a group
of vertices on UH(S2) in which v is a member.
• This computation again takes O(1) time
and processors.
s
( )s t O n
Merging two upper hulls
• Now, we have vertices on UH(S2) and
vertices on UH(S1) .
• There are possible lines if we join one
point from UH(S1) and one point from UH(S2) .
• For each of these O(n) lines, we can check in O(1)
time whether the line is a common tangent to
UH(S1) and UH(S2) .
s t
( )s t O n
Merging two upper hulls
• Suppose, is one such line.
• ul and ur are the two neighboring vertices of u.
Also, vl and vr are the two neighboring vertices of v.
• is the common tangent to both UH(S1) and
UH(S2) if all the point ul, ur, vl, vr are below .
uv
uv
uv
Merging two upper hulls
• For each of the O(n) lines, we can check this condition
in O(1) time.
• Hence, we can find a common tangent to UH(S1) and
UH(S2) in O(1) time and O(n) work.
• We can form another array of vertices containing the
vertices in UH(S1) UH(S2) by deleting some parts of
the arrays of UH(S1) and UH(S2) and merging the
remaining parts.
The convex hull algorithm
• We solve the problem through a divide and
conquer strategy.
• The depth of the recursion is O(log n) and we can
do the merging of the convex hulls at every level
of the recursion in O(1) time and O(n) work.
• Hence, the overall time required is O(log n) and
the overall work done is O(n log n) which is optimal.
• We need the CREW PRAM model due to the
concurrent reading in the parallel search algorithm.
Intersection of half planes
• Consider a line L defined by the equation y = ax + b.
• L divides the entire plane into two half planes,
H+(L) and H-(L).
• H+(L) consists of all the points ( , ) such that
a + b.
• Similarly, H-(L) consists of all the points a + b.
• Intuitively, H+(L) is the set of points on or above the
line L,
• And, H-(L) is the set of points on or below the line L.
Intersection of half planes
• For a set of lines, the intersection of the positive
half planes defined by these lines is a convex
region.
• However, the intersection may or may not be
bounded.
• Our aim is to compute the boundary of the
intersection.
Dual transform
• Let T be a transformation that maps a point
p = (a, b) into the line T(p) defined by y = ax + b.
• The reverse transformation maps the line
L : y = ax + b into the point T(L) = (-a, b).
A property
Property: A point p is below a line L if and only if
T(p) is below the point T(L).
– Consider a set of lines L1, L2,…,Ln, and the region C
defined by 1 i n H+(Li)
– The region C consists of all the points above all the lines
Li,1 i n
Intersection of half planes
• In the transformed domain, T(C+) = { T(p) | p C+ }
consists of all the lines above all the points T(Li),
for 1 i n.
Intersection of half planes
• The extreme points of the intersection of half
planes are now the line segments between two
consecutive vertices of the convex hull in the dual
space.
Intersection of half planes
• To compute the intersection of the half planes,
we first convert the lines into their dual points.
• Then we compute the convex hull of these dual
points.
• Finally, we get the extreme points of the
intersection of half planes by converting the line
segments between two consecutive extreme
points of the convex hull into points.
Intersection of half planes
• The transformations take O(1) time each if
we allocate one processor for each line.
• The convex hull construction takes O(log n)
time and O(n log n) work on the CREW
PRAM.
Two variable linear program
• The two-variable linear program problem is
defined as:
Minimize cx + dy (Objective function)
Subject to: aix + biy + ci 0, 1 i n.
(Constraints)
Two variable linear
programming
• Each constraint is a half plane. The
feasible region is a set of points satisfying
all the constraints.
• The solution of the linear program is a
point in the feasible region that minimizes
the objective function.
• The objective function is minimized at one
of the extreme points of the feasible region.
Two variable linear
programming
• Hence, we can find all the O(n) extreme
points of the feasible region by the half
plane intersection algorithm.
• Then we can find the extreme point which
minimizes the objective function.
• The algorithm takes O(log n) time and
O(n log n) work on the CREW PRAM.

Contenu connexe

Tendances

Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptkarthikaparthasarath
 
Recurrence relation solutions
Recurrence relation solutionsRecurrence relation solutions
Recurrence relation solutionssubhashchandra197
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First SearchKevin Jadiya
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysissumitbardhan
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen ProblemSukrit Gupta
 
Relational algebra ppt
Relational algebra pptRelational algebra ppt
Relational algebra pptGirdharRatne
 
Three address code In Compiler Design
Three address code In Compiler DesignThree address code In Compiler Design
Three address code In Compiler DesignShine Raj
 
Decision Tree - C4.5&CART
Decision Tree - C4.5&CARTDecision Tree - C4.5&CART
Decision Tree - C4.5&CARTXueping Peng
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsMohamed Loey
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithmMohd Arif
 
EULER AND FERMAT THEOREM
EULER AND FERMAT THEOREMEULER AND FERMAT THEOREM
EULER AND FERMAT THEOREMankita pandey
 

Tendances (20)

Np cooks theorem
Np cooks theoremNp cooks theorem
Np cooks theorem
 
Weiler atherton
Weiler athertonWeiler atherton
Weiler atherton
 
K - Nearest neighbor ( KNN )
K - Nearest neighbor  ( KNN )K - Nearest neighbor  ( KNN )
K - Nearest neighbor ( KNN )
 
Hashing
HashingHashing
Hashing
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.ppt
 
Recurrence relation solutions
Recurrence relation solutionsRecurrence relation solutions
Recurrence relation solutions
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 
Random forest
Random forestRandom forest
Random forest
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen Problem
 
convex hull
convex hullconvex hull
convex hull
 
Relational algebra ppt
Relational algebra pptRelational algebra ppt
Relational algebra ppt
 
Three address code In Compiler Design
Three address code In Compiler DesignThree address code In Compiler Design
Three address code In Compiler Design
 
Decision Tree - C4.5&CART
Decision Tree - C4.5&CARTDecision Tree - C4.5&CART
Decision Tree - C4.5&CART
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
 
EULER AND FERMAT THEOREM
EULER AND FERMAT THEOREMEULER AND FERMAT THEOREM
EULER AND FERMAT THEOREM
 
Hashing PPT
Hashing PPTHashing PPT
Hashing PPT
 
Shortest path algorithm
Shortest  path algorithmShortest  path algorithm
Shortest path algorithm
 

En vedette

A novel hybrid crossover based abc algorithm
A novel hybrid crossover based abc algorithmA novel hybrid crossover based abc algorithm
A novel hybrid crossover based abc algorithmDr Sandeep Kumar Poonia
 
Comparative study of_hybrids_of_artificial_bee_colony_algorithm
Comparative study of_hybrids_of_artificial_bee_colony_algorithmComparative study of_hybrids_of_artificial_bee_colony_algorithm
Comparative study of_hybrids_of_artificial_bee_colony_algorithmDr Sandeep Kumar Poonia
 
An improved memetic search in artificial bee colony algorithm
An improved memetic search in artificial bee colony algorithmAn improved memetic search in artificial bee colony algorithm
An improved memetic search in artificial bee colony algorithmDr Sandeep Kumar Poonia
 
Memetic search in differential evolution algorithm
Memetic search in differential evolution algorithmMemetic search in differential evolution algorithm
Memetic search in differential evolution algorithmDr Sandeep Kumar Poonia
 
Sunzip user tool for data reduction using huffman algorithm
Sunzip user tool for data reduction using huffman algorithmSunzip user tool for data reduction using huffman algorithm
Sunzip user tool for data reduction using huffman algorithmDr Sandeep Kumar Poonia
 
Splay trees by NIKHIL ARORA (www.internetnotes.in)
Splay trees by NIKHIL ARORA (www.internetnotes.in)Splay trees by NIKHIL ARORA (www.internetnotes.in)
Splay trees by NIKHIL ARORA (www.internetnotes.in)nikhilarora2211
 
Enhanced local search in artificial bee colony algorithm
Enhanced local search in artificial bee colony algorithmEnhanced local search in artificial bee colony algorithm
Enhanced local search in artificial bee colony algorithmDr Sandeep Kumar Poonia
 
Modified position update in spider monkey optimization algorithm
Modified position update in spider monkey optimization algorithmModified position update in spider monkey optimization algorithm
Modified position update in spider monkey optimization algorithmDr Sandeep Kumar Poonia
 
Multiplication of two 3 d sparse matrices using 1d arrays and linked lists
Multiplication of two 3 d sparse matrices using 1d arrays and linked listsMultiplication of two 3 d sparse matrices using 1d arrays and linked lists
Multiplication of two 3 d sparse matrices using 1d arrays and linked listsDr Sandeep Kumar Poonia
 

En vedette (19)

A novel hybrid crossover based abc algorithm
A novel hybrid crossover based abc algorithmA novel hybrid crossover based abc algorithm
A novel hybrid crossover based abc algorithm
 
Lecture27 linear programming
Lecture27 linear programmingLecture27 linear programming
Lecture27 linear programming
 
Comparative study of_hybrids_of_artificial_bee_colony_algorithm
Comparative study of_hybrids_of_artificial_bee_colony_algorithmComparative study of_hybrids_of_artificial_bee_colony_algorithm
Comparative study of_hybrids_of_artificial_bee_colony_algorithm
 
An improved memetic search in artificial bee colony algorithm
An improved memetic search in artificial bee colony algorithmAn improved memetic search in artificial bee colony algorithm
An improved memetic search in artificial bee colony algorithm
 
RMABC
RMABCRMABC
RMABC
 
Memetic search in differential evolution algorithm
Memetic search in differential evolution algorithmMemetic search in differential evolution algorithm
Memetic search in differential evolution algorithm
 
Sunzip user tool for data reduction using huffman algorithm
Sunzip user tool for data reduction using huffman algorithmSunzip user tool for data reduction using huffman algorithm
Sunzip user tool for data reduction using huffman algorithm
 
Splay tree
Splay treeSplay tree
Splay tree
 
Lecture25
Lecture25Lecture25
Lecture25
 
Splay Tree
Splay TreeSplay Tree
Splay Tree
 
Splay trees by NIKHIL ARORA (www.internetnotes.in)
Splay trees by NIKHIL ARORA (www.internetnotes.in)Splay trees by NIKHIL ARORA (www.internetnotes.in)
Splay trees by NIKHIL ARORA (www.internetnotes.in)
 
Enhanced local search in artificial bee colony algorithm
Enhanced local search in artificial bee colony algorithmEnhanced local search in artificial bee colony algorithm
Enhanced local search in artificial bee colony algorithm
 
Modified position update in spider monkey optimization algorithm
Modified position update in spider monkey optimization algorithmModified position update in spider monkey optimization algorithm
Modified position update in spider monkey optimization algorithm
 
2-3 Tree
2-3 Tree2-3 Tree
2-3 Tree
 
Multiplication of two 3 d sparse matrices using 1d arrays and linked lists
Multiplication of two 3 d sparse matrices using 1d arrays and linked listsMultiplication of two 3 d sparse matrices using 1d arrays and linked lists
Multiplication of two 3 d sparse matrices using 1d arrays and linked lists
 
Lecture26
Lecture26Lecture26
Lecture26
 
Soft computing
Soft computingSoft computing
Soft computing
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
 
Lecture28 tsp
Lecture28 tspLecture28 tsp
Lecture28 tsp
 

Similaire à Lecture24 (20)

Unit-5 BSR-1-02-2024 advanced algorithms .pptx
Unit-5 BSR-1-02-2024 advanced algorithms .pptxUnit-5 BSR-1-02-2024 advanced algorithms .pptx
Unit-5 BSR-1-02-2024 advanced algorithms .pptx
 
sorting
sortingsorting
sorting
 
MATLABgraphPlotting.pptx
MATLABgraphPlotting.pptxMATLABgraphPlotting.pptx
MATLABgraphPlotting.pptx
 
Lecture 9-online
Lecture 9-onlineLecture 9-online
Lecture 9-online
 
Polygon Fill
Polygon FillPolygon Fill
Polygon Fill
 
machine learning.pptx
machine learning.pptxmachine learning.pptx
machine learning.pptx
 
Lect no 13 ECC.ppt
Lect no 13 ECC.pptLect no 13 ECC.ppt
Lect no 13 ECC.ppt
 
Lect no 13 ECC.ppt
Lect no 13 ECC.pptLect no 13 ECC.ppt
Lect no 13 ECC.ppt
 
5_6221983039971394498.pptx
5_6221983039971394498.pptx5_6221983039971394498.pptx
5_6221983039971394498.pptx
 
unit-4-dynamic programming
unit-4-dynamic programmingunit-4-dynamic programming
unit-4-dynamic programming
 
Unit ix graph
Unit   ix    graph Unit   ix    graph
Unit ix graph
 
Lec 1.0.pptx
Lec 1.0.pptxLec 1.0.pptx
Lec 1.0.pptx
 
curve one
curve onecurve one
curve one
 
Unit 9 graph
Unit   9 graphUnit   9 graph
Unit 9 graph
 
141222 graphulo ingraphblas
141222 graphulo ingraphblas141222 graphulo ingraphblas
141222 graphulo ingraphblas
 
141205 graphulo ingraphblas
141205 graphulo ingraphblas141205 graphulo ingraphblas
141205 graphulo ingraphblas
 
testpang
testpangtestpang
testpang
 
DAA Notes.pdf
DAA Notes.pdfDAA Notes.pdf
DAA Notes.pdf
 
Merge sort
Merge sortMerge sort
Merge sort
 
Floor planning ppt
Floor planning pptFloor planning ppt
Floor planning ppt
 

Plus de Dr Sandeep Kumar Poonia

Improved onlooker bee phase in artificial bee colony algorithm
Improved onlooker bee phase in artificial bee colony algorithmImproved onlooker bee phase in artificial bee colony algorithm
Improved onlooker bee phase in artificial bee colony algorithmDr Sandeep Kumar Poonia
 
New Local Search Strategy in Artificial Bee Colony Algorithm
New Local Search Strategy in Artificial Bee Colony Algorithm New Local Search Strategy in Artificial Bee Colony Algorithm
New Local Search Strategy in Artificial Bee Colony Algorithm Dr Sandeep Kumar Poonia
 
Performance evaluation of different routing protocols in wsn using different ...
Performance evaluation of different routing protocols in wsn using different ...Performance evaluation of different routing protocols in wsn using different ...
Performance evaluation of different routing protocols in wsn using different ...Dr Sandeep Kumar Poonia
 
Performance evaluation of diff routing protocols in wsn using difft network p...
Performance evaluation of diff routing protocols in wsn using difft network p...Performance evaluation of diff routing protocols in wsn using difft network p...
Performance evaluation of diff routing protocols in wsn using difft network p...Dr Sandeep Kumar Poonia
 
Problems in parallel computations of tree functions
Problems in parallel computations of tree functionsProblems in parallel computations of tree functions
Problems in parallel computations of tree functionsDr Sandeep Kumar Poonia
 

Plus de Dr Sandeep Kumar Poonia (16)

Improved onlooker bee phase in artificial bee colony algorithm
Improved onlooker bee phase in artificial bee colony algorithmImproved onlooker bee phase in artificial bee colony algorithm
Improved onlooker bee phase in artificial bee colony algorithm
 
New Local Search Strategy in Artificial Bee Colony Algorithm
New Local Search Strategy in Artificial Bee Colony Algorithm New Local Search Strategy in Artificial Bee Colony Algorithm
New Local Search Strategy in Artificial Bee Colony Algorithm
 
A new approach of program slicing
A new approach of program slicingA new approach of program slicing
A new approach of program slicing
 
Performance evaluation of different routing protocols in wsn using different ...
Performance evaluation of different routing protocols in wsn using different ...Performance evaluation of different routing protocols in wsn using different ...
Performance evaluation of different routing protocols in wsn using different ...
 
Enhanced abc algo for tsp
Enhanced abc algo for tspEnhanced abc algo for tsp
Enhanced abc algo for tsp
 
Database aggregation using metadata
Database aggregation using metadataDatabase aggregation using metadata
Database aggregation using metadata
 
Performance evaluation of diff routing protocols in wsn using difft network p...
Performance evaluation of diff routing protocols in wsn using difft network p...Performance evaluation of diff routing protocols in wsn using difft network p...
Performance evaluation of diff routing protocols in wsn using difft network p...
 
Lecture23
Lecture23Lecture23
Lecture23
 
Problems in parallel computations of tree functions
Problems in parallel computations of tree functionsProblems in parallel computations of tree functions
Problems in parallel computations of tree functions
 
Parallel Algorithms
Parallel AlgorithmsParallel Algorithms
Parallel Algorithms
 
Parallel Algorithms
Parallel AlgorithmsParallel Algorithms
Parallel Algorithms
 
Parallel Algorithms
Parallel AlgorithmsParallel Algorithms
Parallel Algorithms
 
Network flow problems
Network flow problemsNetwork flow problems
Network flow problems
 
Shortest Path in Graph
Shortest Path in GraphShortest Path in Graph
Shortest Path in Graph
 
Topological Sort
Topological SortTopological Sort
Topological Sort
 
Graph
GraphGraph
Graph
 

Dernier

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Dernier (20)

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

Lecture24

  • 1. An overview of lecture • Geometric Algorithms – Range searching. – Nearest neighbor. – Finding intersections of geometric objects. • An optimal parallel algorithm for the 2D convex hull problem, • Some applications of the 2D convex hull algorithm.
  • 2. Geometric search: Overview • Types of data. Points, lines, planes, polygons, circles, ... • This lecture: Sets of N objects. • Geometric problems extend to higher dimensions. – Good algorithms also extend to higher dimensions. – Curse of dimensionality. • Basic problems. – Range searching. – Nearest neighbor. – Finding intersections of geometric objects.
  • 3. Range Searching 1D Range Search • Extension to symbol-table ADT with comparable keys. – Insert key-value pair. – Search for key k. – How many records have keys between k1 and k2? – Iterate over all records with keys between k1 and k2. • Application: database queries. • Geometric intuition. – Keys are point on a line. – How many points in a given interval? insert B B insert D B D insert A A B D insert I A B D I insert H A B D H I insert F A B D F H I insert P A B D F H I P count G to K 2 search G to K H I
  • 4. 1D Range Search Implementations • Range search. How many records have keys between k1 and k2? • Ordered array. Slow insert, binary search for k1 and k2 to find range. • Hash table. No reasonable algorithm (key order lost in hash). • BST. In each node x, maintain number of nodes in tree rooted at x. Search for smallest element k1 and largest element k2. log N N log N countinsert range ordered array N R + log N hash table 1 N BST log N R + log N nodes examined within interval not touched N = # records R = # records that match
  • 5. 2D Orthogonal Range Search • Extension to symbol-table ADT with 2D keys. – Insert a 2D key. – Search for a 2D key. – Range search: find all keys that lie in a 2D range? – Range count: how many keys lie in a 2D range? • Applications: networking, circuit design, databases. • Geometric interpretation. – Keys are point in the plane. – Find all points in a given h-v rectangle?
  • 6. 2D Orthogonal Range Search: Grid Implementation • Grid implementation. – Divide space into M-by-M grid of squares. – Create linked list for each square. – Use 2D array to directly access relevant square. – Insert: insert (x, y) into corresponding grid square. – Range search: examine only those grid squares that could have points in the rectangle. LB RT
  • 7. 2D Orthogonal Range Search: Grid Implementation Costs • Space-time tradeoff. – Space: M2 + N. – Time: 1 + N / M2 per grid cell examined on average. • Choose grid square size to tune performance. – Too small: wastes space. – Too large: too many points per grid square. – Rule of thumb: √N by √N grid. • Running time. [if points are evenly distributed] – Initialize: O(N). – Insert: O(1). – Range: O(1) per point in range. LB RT
  • 8. Clustering • Grid implementation. Fast, simple solution for well-distributed points. • Problem. Clustering is a well-known phenomenon in geometric data. • Ex: USA map data. – 80,000 points, 20,000 grid squares. – Half the grid squares are empty. – Half the points have 10 others in same grid square. – Ten percent have 100 others in same grid square. • Need data structure that gracefully adapts to data.
  • 9. Space Partitioning Trees • Space partitioning tree. Use a tree to represent the recursive hierarchical subdivision of d-dimensional space. • BSP tree:- Recursively divide space into two regions. • Quad tree:- Recursively divide plane into four quadrants. • Octree:- Recursively divide 3D space into eight octants. • kD tree:- Recursively divide k-dimensional space into two half- spaces. • Applications. – Ray tracing. – Flight simulators. – N-body simulation. – Collision detection. – Astronomical databases. – Adaptive mesh generation. – Accelerate rendering in Doom. – Hidden surface removal and shadow casting. Grid Quadtree kD tree BSP tree
  • 10. Quad Trees • Quad tree. Recursively partition plane into 4 quadrants. • Implementation: 4-way tree. • Good clustering performance is a primary reason to choose quad trees over grid methods. a b c e f g h d a h d ge b c f public class QuadTree { private Quad quad; private Value value; private QuadTree NW, NE, SW, SE; }
  • 11. kD Trees • kD tree. Recursively partition k-dimensional space into 2 halfspaces. • Implementation: BST, but cycle through dimensions. • Efficient, simple data structure for processing k-dimensional data. – Adapts well to clustered data. – Adapts well to high dimensional data. – Discovered by an undergrad in an algorithms class! level ≡ i (mod k) points whose ith coordinate is less than p’s points whose ith coordinate is greater than p’s p
  • 12. Summary • Basis of many geometric algorithms: search in a planar subdivision. grid 2D tree Voronoi diagram intersecting lines basis N h-v lines N points N points N lines representation 2D array of N lists N-node BST N-node multilist ~N-node BST cells ~N squares N rectangles N polygons ~N triangles search cost 1 log N log N log N extend to kD? too many cells easy cells too complicated use (k-1)D hyperplane
  • 13. Geometric Intersection • Problem. Find all intersecting pairs among set of N geometric objects. • Applications. CAD, games, movies, virtual reality. • Simple version: 2D, all objects are horizontal or vertical line segments. • Brute force. Test all (N2) pairs of line segments for intersection. • Sweep line. Efficient solution extends to 3D and general objects.
  • 14. • Sweep vertical line from left to right. – Event times: x-coordinates of h-v line segments. – Left endpoint of h-segment: insert y coordinate into ST. – Right endpoint of h-segment: remove y coordinate from ST. – v-segment: range search for interval of y endpoints. Orthogonal Segment Intersection: Sweep Line Algorithm range searchinsert y delete y
  • 15. Orthogonal Segment Intersection: Sweep Line Algorithm • Sweep line: reduces 2D orthogonal segment intersection problem to 1D range searching! • Running time of sweep line algorithm. – Put x-coordinates on a PQ (or sort). O(N log N) – Insert y-coordinate into SET. O(N log N) – Delete y-coordinate from SET. O(N log N) – Range search. O(R + N log N) • Efficiency relies on judicious use of data structures. N = # line segments R = # intersections
  • 16. Line Segment Intersection: Implementation • Efficient implementation of sweep line algorithm. – Maintain PQ of important x-coordinates: endpoints and intersections. – Maintain ST of segments intersecting sweep line, sorted by y. – O(R log N + N log N). • Implementation issues. – Degeneracy. – Floating point precision. – Use PQ since intersection events aren't known ahead of time.
  • 17. The convex hull problem Input: A set S = (p1, p2,…,pn) of n points on the plane. Output: The convex hull CH(S) of these n points. • The convex hull is the smallest convex polygon containing all the n points. • Each vertex of CH(S) is called an extreme point and the convex hull is output as a list of the extreme points.
  • 18. The convex hull problem • Let pmax and pmin be two points in the set S with the maximum and minimum x coordinates. • Then pmax and pmin are convex hull vertices. • The line segment divides the convex hull into two parts, upper hull and lower hull. max minp p
  • 19. The convex hull problem • We use the notation x(p) and y(p) to denote the x and y coordinates of a point p. • Given a line L specified by the equation y = ax + b, and a point q =( , ), • We say, q is below L if < a + b. • We also say, q is above L if > a + b.
  • 20. The convex hull problem • Given the set S of n points, we can find pmax and pmin in O(n) time. • We can find all the points above and below also in O(n) time. • We can compute the convex hull of all the points above and call this as UH(S). • Similarly, we can compute the convex hull of all the points below and call this as LH(S). • At the end, we can stitch these two hulls together at the two points pmax and pmin. max minp p max minp p max minp p
  • 21. Sequential complexity • The convex hull of n planar points can be constructed in (n log n) time sequentially. • The lower bound can be proved by showing that the convex hull problem is equivalent to sorting. • We need to design an O(n log n) work algorithm to achieve optimality.
  • 22. Computing the upper hull • We will discuss an algorithm for computing the upper hull of the set S. The algorithm for computing the lower hull is exactly the same. • A line L is tangent to a convex polygon P if all the vertices of P are on the same side of L.
  • 23. A divide-and-conquer algorithm • We discuss a divide-and-conquer algorithm for computing the upper hull. There are two phases, top-down and bottom-up. • First, we sort the points according to x- coordinates.
  • 24. A divide-and-conquer algorithm • In the top-down phase, we divide the point set recursively into two parts and compute the convex hull when the size of each subproblem is small. • In the bottom-up phase, we merge these hulls pairwise to get the upper hull. • The strategy is exactly similar to the sequential algorithm for merge sort.
  • 26. Merging two upper hulls • The main problem in combining two upper hulls to form a single upper hull is to compute a common tangent to the two hulls. • To achieve O(n log n) work, we need to complete the merging of all the upper hulls at a level of the tree in O(1) time.
  • 27. Merging two upper hulls • We consider two upper hulls UH(S1) and UH(S2). • Our aim is to find a common tangent to these two upper hulls. • We first find a tangent to UH(S2) from a point ri on UH(S1).
  • 28. Merging two upper hulls • Suppose the line is the tangent to UH(S2) from ri. • Suppose ql is another vertex of UH(S2). • Given the line riql, we first try to locate . ii rrq irq
  • 29. Merging two upper hulls • In O(1) time, we can say whether is above or below the line . • If the neighboring vertices ql -1 and ql +1 of ql are on either side of , then is above ql. irq irq i lrq i lrq
  • 30. Merging two upper hulls • Suppose, UH(S2) has s points given in an array according to their order on UH(S2). • We allocate processors and divide the points on UH(S2) into intervals and do a parallel search. • We can identify the point in time. s irq log ( ) (1) log s O O s s
  • 31. Merging two upper hulls • Suppose, the common tangent to UH(S1) and UH(S2) is the line . • u is on UH(S1) and v is on UH(S2) . • If we know the line , we can say in O(1) time whether u is above or below the line . uv ii rrq ii rrq
  • 32. Merging two upper hulls • Suppose, there are t points on UH(S1), given in an array according to their order on UH(S1). • We divide these t points in intervals, each interval contains points. • We now do a parallel search in the following ways. t t
  • 33. Merging two upper hulls • We allocate processors for the parallel search. • Suppose ri is the boundary vertex of one of the intervals. • For each such ri, we can find the tangent to UH(S2) in O(1) time using processors. t s s ii rrq
  • 34. Merging two upper hulls • Hence, we can identify two boundary vertices rj and rk such that u is above rj and below rk. • Hence, u must be one of the vertices in between rj and rk. • This computation takes O(1) time and processors. t ( )s t O n
  • 35. Merging two upper hulls • We can do a similar computation to find a group of vertices on UH(S2) in which v is a member. • This computation again takes O(1) time and processors. s ( )s t O n
  • 36. Merging two upper hulls • Now, we have vertices on UH(S2) and vertices on UH(S1) . • There are possible lines if we join one point from UH(S1) and one point from UH(S2) . • For each of these O(n) lines, we can check in O(1) time whether the line is a common tangent to UH(S1) and UH(S2) . s t ( )s t O n
  • 37. Merging two upper hulls • Suppose, is one such line. • ul and ur are the two neighboring vertices of u. Also, vl and vr are the two neighboring vertices of v. • is the common tangent to both UH(S1) and UH(S2) if all the point ul, ur, vl, vr are below . uv uv uv
  • 38. Merging two upper hulls • For each of the O(n) lines, we can check this condition in O(1) time. • Hence, we can find a common tangent to UH(S1) and UH(S2) in O(1) time and O(n) work. • We can form another array of vertices containing the vertices in UH(S1) UH(S2) by deleting some parts of the arrays of UH(S1) and UH(S2) and merging the remaining parts.
  • 39. The convex hull algorithm • We solve the problem through a divide and conquer strategy. • The depth of the recursion is O(log n) and we can do the merging of the convex hulls at every level of the recursion in O(1) time and O(n) work. • Hence, the overall time required is O(log n) and the overall work done is O(n log n) which is optimal. • We need the CREW PRAM model due to the concurrent reading in the parallel search algorithm.
  • 40. Intersection of half planes • Consider a line L defined by the equation y = ax + b. • L divides the entire plane into two half planes, H+(L) and H-(L). • H+(L) consists of all the points ( , ) such that a + b. • Similarly, H-(L) consists of all the points a + b. • Intuitively, H+(L) is the set of points on or above the line L, • And, H-(L) is the set of points on or below the line L.
  • 41. Intersection of half planes • For a set of lines, the intersection of the positive half planes defined by these lines is a convex region. • However, the intersection may or may not be bounded. • Our aim is to compute the boundary of the intersection.
  • 42. Dual transform • Let T be a transformation that maps a point p = (a, b) into the line T(p) defined by y = ax + b. • The reverse transformation maps the line L : y = ax + b into the point T(L) = (-a, b).
  • 43. A property Property: A point p is below a line L if and only if T(p) is below the point T(L). – Consider a set of lines L1, L2,…,Ln, and the region C defined by 1 i n H+(Li) – The region C consists of all the points above all the lines Li,1 i n
  • 44. Intersection of half planes • In the transformed domain, T(C+) = { T(p) | p C+ } consists of all the lines above all the points T(Li), for 1 i n.
  • 45. Intersection of half planes • The extreme points of the intersection of half planes are now the line segments between two consecutive vertices of the convex hull in the dual space.
  • 46. Intersection of half planes • To compute the intersection of the half planes, we first convert the lines into their dual points. • Then we compute the convex hull of these dual points. • Finally, we get the extreme points of the intersection of half planes by converting the line segments between two consecutive extreme points of the convex hull into points.
  • 47. Intersection of half planes • The transformations take O(1) time each if we allocate one processor for each line. • The convex hull construction takes O(log n) time and O(n log n) work on the CREW PRAM.
  • 48. Two variable linear program • The two-variable linear program problem is defined as: Minimize cx + dy (Objective function) Subject to: aix + biy + ci 0, 1 i n. (Constraints)
  • 49. Two variable linear programming • Each constraint is a half plane. The feasible region is a set of points satisfying all the constraints. • The solution of the linear program is a point in the feasible region that minimizes the objective function. • The objective function is minimized at one of the extreme points of the feasible region.
  • 50. Two variable linear programming • Hence, we can find all the O(n) extreme points of the feasible region by the half plane intersection algorithm. • Then we can find the extreme point which minimizes the objective function. • The algorithm takes O(log n) time and O(n log n) work on the CREW PRAM.