CS 506: Solution to Homework #3 |
Problem 1: a simple polygon is called star-shaped
if there exists a point q in the interior of the polygon from which
every interior point is visible (that is, such that, for any point p
within the polygon, the segment pq does not cross the perimeter).
a. Show that, given a star-shaped polygon and its special point q,
we can store the polygon in such a way that the query "is point r=(x,y)
within the polygon" can be answered in O(log n) time.
We do this by binary search: since every point within the polygon is
visible from point q, we can divide the polygon into triangles
by drawing a segment from q to each of the polygon's vertices.
Binary search will locate the proper cone in logarithmic time (some
precautions must be taken because the search range is circular,
but binary search is designed for linear ranges), then a constant-time
test will determine on which side of the perimeter edge the query point
lies.
b. What if the polygon is in fact star-shaped, but you have not been
given the special point q? How efficiently can a suitable value for q
be obtained?
That is a harder question. An easy solution is the following:
to each edge of the perimeter corresponds a partition into half planes
and by turning around the perimeter, a consistent orientation for these
partitions is determined. If a special point q exists, then it must
be on the same side of every one of these partitions, so it suffices
to intersect all "inside" half-planes determined by the edges of the
polygon. If the result is empty, then the claim that the polygon was
star-shaped was false; otherwise, any point within the convex polygon
that is the intersection is a valid choice. The cost is O(nlogn)
using our divide-and-conquer algorithm for half-plane intersection.
The real question, then, is whether we can exploit the nature of
the problem to run faster.
The answer is yes: it can be done in linear time (it is one of the oldest results in computational geometry, by Lee and Preparata, in 1979, appearing in JACM). The algorithm is not even that complex: go around the perimeter and compute on the fly the intersection of the half-planes defined by the edges seen so far -- no divide-and-conquer, but a simple incremental computation. The trick is that intersecting the existing intersection polygon with the next half-plane can be done in amortized constant time, because we know a lot about the next half-plane. We shall maintain the tangency points to the current intersection from the next vertex on the perimeter of the given polygon and use them in handling the next edge; note that maintaining these tangency points is simply a matter of turning around the (convex) intersection figure and, in the worst case, will have required us to turn all the way around the intersection figure through the execution of the algorithm, which clearly takes linear time overall and thus constant amortized time per operation. With the help of the tangency points, it is a simple matter to compute the intersection with the new half-plane, again by walking the boundary of the current intersection polygon, and again for a total cost of O(n) overall.
Problem 2: A Voronoi diagram is really a proximity structure:
one can use it to answer all sorts of proximity-related queries.
Show that, given the Voronoi diagram, we can compute in O(n) time
the nearest neighbor of each site in the set of sites.
The main claim is that the nearest neighbor is always a site in an
adjacent Voronoi diagram -- a claim that is obviously true from the
definition of the Voronoi diagram. Now consider working in the dual
graph (the Delaunay triangulation): for each vertex, we must scan
all incident edges and find the shortest. But, by Euler's formula
for triangulations, the sum of the degrees of all vertices is O(n),
and thus so is the running time of our algorithm.
Problem 3: We mentioned that Voronoi diagrams and convex
hulls are closely related.
a. Show that, given the Voronoi diagram (as a DCEL inside a bounding
box), we can compute the convex hull of the set of sites in linear time,
in fact, in time linear in the size of the output.
Getting plain linear time is easy: walk the diagram (using the DCEL) to
find a Voronoi polygon that touches the bounding box, then walk the
"perimeter" (i.e., follow the perimeter of the current polygon along
the boundary box edge to get the edge of the next boundary polygon).
Getting time linear in the size of the output simply requires getting
the first polygon fast -- but we can do that from a pointer to one
of the bounding box edges; after that, the work done to move from one
boundary polygon to the next is constant, because we move along the bounding
box rather than around the hull itself.
b. Conclude that computing the Voronoi diagram takes Omega(nlogn) time
in the worst case in a comparison-based model of computation.
Finding nearest-neighbor pairs solves the element uniqueness problem,
which is know to require Omega(nlogn) comparisons.
| Back to CS 506 home page |